How can I receive data (byte stream) from an open network socket in C on a packet-by-packet basis? I want to read data from the socket IMMEDIATELY as it arrives (as soon as the packet arrives on the machine).
It seems when I perform a read() (or recv()) call on the socket, I am getting the entire TCP message of 10,000+ bytes. Rather, I would like to receive the first TCP segment payload, process it, then continue to the next, etc.
Note - I don't want raw packets. Just the TCP segment data payload.
Also note - In essence I want to minimize delay by processing data immediately as it arrives, as opposed to waiting for the entire TCP message to accumulate in the TCP layer.
Any ideas would be much appreciated, thanks!
tcpdump
show? – Karoly HorvathTCP_NODELAY
is a transmit option – Alnitak