Signal interrupt sendto/recvfrom on datagram socket

50 Views Asked by At

What happens if signal interrupts sendto or recvfrom call on datagram socket? Can I expect that these calls always return -1 with errno == EINTR or they can return positive number of bytes, but I shall repeat the call entirely?

1

There are 1 best solutions below

0
On

On a datagram socket, sendto and recvfrom always send and receive complete datagrams, or nothing at all. If they could stop in the middle of a datagram that would defeat the point of datagrams.

There is an exception - recvfrom might cut off the end of a datagram if the buffer is too small. The entire datagram is received, but your program doesn't get to see all of it.