Both read
and write
return the number of bytes read/written, or -1 on error.
Note, that to be able to invoke read
/write
on a UDP socket (or, more generally, on a datagram socket) you have to invoke connect
on it beforehand to specify the peer address.