You are not logged in.
Pages: 1
This is on Linux 2.4.I am using writev with 2 vectors on a blocking socket. It happens rarely, but it does and I dont know why ... I get a partial write return ( eg 1000 when the total size of the two buffers is 1400 ).
If anyone has any ideas, please. This really shouldnt happen.
Offline
Yes, I've seen that behavior before as well (though, with sendmsg() and its iovecs)...
And, actually, no it's NOT incorrect/unexpected behavior... Both read()/recv() and
write()/send() (and all permutations of the I/O funcs) can return short reads/writes,
and all sockets code needs to be prepared to deal with that... It doesn't matter if
they're blocking or non-blocking mode sockets, either... All that controls is what
happens when the buffer is totally empty (in the case of input) or totally full (in the
case of output)... But, when the send buffer isn't quite full, any write to it (via a
blocking or non-blocking socket) of more than the amount of free space left will
write as much as it can, and then return the short write count... And, you are
expected to handle calling it again, to send the remaining amount... With normal
write()/send(), it's easy to do, but with writev()/sendmsg() iovecs, it does become
tricky to handle, and a real pain... But, you still MUST do it, nonetheless, I'm afraid...
(I'm not sure if it's the case that the iovec output funcs are more prone to this sort
of behavior, or it's just the fact that one is typically sending more data when using
them, which causes it to occur more frequently... But, I've definitely been bitten by
failing to properly handle a short write from sendmsg() before, as well...)
Offline
Thanks much, Rob. Yes, I am unfortunately resigning myself
to doing the partial write handling; just needed some confirmation
that this sort of thing is not some wierd problem with my code
or use of fcntl.
Offline
Pages: 1