Date: Tue, 20 Jan 2004 08:22:09 -0800 From: Justin Walker <justin@mac.com> To: freebsd-hackers@freebsd.org Subject: Re: send(2) does not block, send(2) man page wrong? Message-ID: <CBDD3D34-4B64-11D8-A64D-00306544D642@mac.com> In-Reply-To: <E1Aice9-0002by-00@roo>
next in thread | previous in thread | raw e-mail | index | archive | help
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 *--------------------------------------*-------------------------------*
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CBDD3D34-4B64-11D8-A64D-00306544D642>