WSAStartup error

Apr 5, 2012 at 9:58 AM
Edited Apr 9, 2012 at 7:54 AM

Hi,

The following problem happens with 0.9.0.66492 and 0.8.0.54547 versions. When I am running the following code I get the error:

"Failed reading from device. WinPcap Error: select(): Either the application has not called WSAStartup, or WSAStartup failed.  (code 10093)".

I have tried to fix that using "netsh winsock reset". I also reinstalled winpcap 4.1.2. All these actions didn't help. Here is the code fragment:

 

var device = new OfflinePacketDevice("Traffic.pcap");

Packet packet;

 

using (var  

 

communicator = device.Open())

 

 

{

communicator.SetFilter("ip and udp" 

);   

 

 

 

communicator.ReceivePacket(out

packet);  

while (packet != null)

 

 

 

{

 

if (packetFilter(packet))  

 

 

{

 yield return

packet;
 

 

 

}

communicator.ReceivePacket(out

packet);
 

 

 

 

 

}

}

 

 

 

packetFilter is my method. The error is thrown from ReceivePacket.

Thanks

Apr 5, 2012 at 2:29 PM

Please note: If I am using ReceivePackets instead the error does not reproduce.

Coordinator
Apr 11, 2012 at 10:36 AM

I've run this code:

            var device = new OfflinePacketDevice(@"SomeFileWithManyPackets.pcap");

            Packet packet;

            using (var communicator = device.Open())
            {
                communicator.SetFilter("ip and udp");
                communicator.ReceivePacket(out packet);
                while (packet != null)
                {
                    communicator.ReceivePacket(out packet);
                }
            }

 

And it seems to work.

Maybe some more information would help debugging this:

1. Does the error happens in the first iteration?

2. Can you send me the pcap file you're using?

3. What is the return value from ReceivePacket() when it doesn't throw an exception?

4. Can you write packetFilter() function?

5. Did you make sure you follow all of the instructions in Pcap.Net user guide - Using Pcap.Net in your programs?

6. Does removing the filter prevents this error?

7. Can you minimize the code that reproduces this error?

 

Boaz.