I’m just trying to understand how does non-blocking recvfrom works? I’m writing an application that communicates with the certain device that sends data at about 10 Mbps speed. I’ve made infinte loop that calls recvfrom successively and strip off the header and copy rest of message in some temporary buffer. Now my question is:
Does single call of non-blocking recvfrom (considering there is data available) returns only one packet? Or it is possible that single recvfrom may return multiple concatenated packets as well?
UPDATE
Yes, I’m using connectionless socket (UDP).
Only one datagram in the case of UDP. Concatenating packets would violate one of the (few) fundamental guarantees made by that protocol: that the boundaries between datagrams sent are preserved.
Recent versions of Linux have
recvmmsgthat lets you receive multiple datagrams per syscall.