0

I am using Pcap.Net to transmit packet through my machine adapter, i some cases i am read packets from several files in the same time using Parallel.ForEach with MaxDegreeOfParallelism property that can be changed. So i wonder if i need to lock the object that sent this packet..

This is how my main send the packets:

// Open the my device
using (PacketCommunicator communicator = selectedDevice.Open(100, PacketDeviceOpenAttributes.Promiscuous, 1000))                                                        
{
    Packet packet;

    // Read packet from file
    while (inputCommunicator.ReceivePacket(out packet) == PacketCommunicatorReceiveResult.Ok)
    {
       // Send packet
       communicator.SendPacket(packet);
    }
}
dina ere
  • 53
  • 8

1 Answers1

0

From what I understand of WinPcap, I believe that if you don't use the same PacketCommunicator in two threads in parallel, you should be fine.

brickner
  • 6,595
  • 3
  • 41
  • 54