Re: [Newbie] send() blocks or not

From: Senthilraja (senthil.raja_at_adcc.alcatel.be)
Date: 08/28/03


Date: Thu, 28 Aug 2003 09:47:40 +0530

Chuck Dillon wrote:

> Senthilraja wrote:
> > Hello All,
> >
> > Can someone please let me know if send() call block or unblocks? Suppose
> > the kernel is unable to send all the bytes sepcified by the length
> > argument, does it blocks until it sends all the bytes, or it returns to
> > the process the number of bytes it managed to send.
> >
> > I read a tutorial document and the man pages (in Solaris) and both the
> > info are contradictory.
> >
> > regards,
> > Senthilraja.
> >
> >
>
> From the send manpage on solaris:
>
> If the socket does not have enough buffer space available to
> hold the message being sent, send() blocks, unless the
> socket has been placed in non-blocking I/O mode (see
> fcntl(2)). The select(3C) or poll(2) call may be used to
> determine when it is possible to send more data.
>
> The Linux manpage says basically the same thing.
>
> What isn't clear?
>
> -- ced
>
> --
> Chuck Dillon
> Senior Software Engineer
> NimbleGen Systems Inc.

Solaris man page says that send() blocks (provided, the socket option is not
set to non-blocking) until all the bytes are written to the send buffer.

However, in a tutorial document found in the web it is mentioned that send()
is non-blocking and returns the number of bytes it managed to send. So, this
document nust be wrong then.

Thanks and regards,
Senthilraja.