So I've been having an issue with the receive functionality with the PCap library.
I set up an echo server (outside my PC) that just takes a packet and turns it around. So, in my application, I send a packet (that works fine) and I tried receiving the response packet (from the echo server) with pcap_next(). For some reason, it would wait 1 whole second to receive the packet with pcap_next(), even though Wireshark shows the packet being turned around in less than 1ms. Thus, when I send 1000 packets, it takes 1000 seconds to receive all the responses.
I couldn't figure out why it was doing that, so I tried switching to pcap_loop(). Apparently now it's doing something even more strange. I send 1000 packets, and receive 1000 packets, but not in the order I would expect.
I expect this (this is what I see on Wireshark):
Send packet #1
Receive packet #1
Send packet #2
Receive packet #2
etc.
But this is what I really get:
Send packet #1
Send packet #2
etc.
Wait 1 second
Receive packet #1
Receive packet #2
etc.
What's going on here?
setsockopt
w/TCP_NODELAY
? ( Throwing that out there randomly...I only just read about this recently, wondering if it would be relevant: en.wikipedia.org/wiki/Nagle%27s_algorithm ) – HostileFork says dont trust SE