Youda008
Youda008

Reputation: 1949

In which case does sendto() on UDP socket return 0?

Is there a case, when calling of sendto() on UDP socket returns 0 and if yes, what does it mean? Manual only says, that on error it's -1, otherwise it's number of bytes sent.

Upvotes: 4

Views: 3100

Answers (1)

Jeff
Jeff

Reputation: 3525

You can send()/sendto() a zero-byte message on a domain datagram or UDP socket, in which case a returned length of 0 bytes is correct. If you are seeing this unexpectedly, verify your len parameter in your sendto(int fd, void const *buf, size_t len, int flags, struct const *dest, sockles_t addrlen) call.

Upvotes: 5

Related Questions