send(2) does not block, send(2) man page wrong?

Justin Walker justin at mac.com
Tue Jan 20 08:22:27 PST 2004


On Monday, January 19, 2004, at 08:53 AM, Stuart Pook wrote:

> The documentation for send(2) says
>
> 	If no messages space is available at the socket to hold the message 
> to be
> 	transmitted, then send() normally blocks, unless the socket has been
> 	placed in non-blocking I/O mode.  The select(2) call may be used to
> 	determine when it is possible to send more data.
> 	
> I cannot get send (or sendto which is what is really interests me)
> to block on FreeBSD 4.9.  When I send as fast as I can to a socket,
> send rapidly fails with ENOBUFS.  I am not surprised that the kernel is
> running out of mbufs but I am surprised that send does not block until
> more become available.
>
> Select does not block either.  It always says that I can write to the
> socket and then send fails with ENOBUFS.
>
> The udp_output function in /sys/netinet/udp_usrreq.c, seems clear:

UDP does not have a need to block, so it does not.  The UDP delivery 
'promise' is best effort, and datagrams will get spilled anywhere along 
the route to the destination (no user crying over ...).

If you use TCP, which has a need to block, your sending process will be 
blocked until both local and remote buffering space is available.

You could make a case that the man page for 'send(2)' is either 
inaccurate or misleading.  The problem is that 'send()' actually 
doesn't handle this; as your post indicates, the decision to block or 
fail a transmission is taken at the protocol level, and 'send()' is 
generally blind to that.

Cheers,

Justin

--
Justin C. Walker, Curmudgeon-At-Large  *
Institute for General Semantics        |   If you're not confused,
                                        |   You're not paying attention
*--------------------------------------*-------------------------------*



More information about the freebsd-hackers mailing list