Sockets programming question

Adrian Chadd adrian at freebsd.org
Tue Jan 29 17:56:50 UTC 2013


On 29 January 2013 09:46, Ian Lepore <ian at freebsd.org> wrote:

> You can't use EOF on a read() to determine client life when the nature
> of the client/server relationship is that clients are allowed to
> shutdown(fd, SHUT_WR) as soon as they connect because they expect to
> receive but never send any data.
>
> On the other hand, Alfred's suggestion of using poll(2) rather than
> select(2) worked perfectly.  Polling with an events mask of zero results
> in it returning POLLHUP in revents if the client has closed the socket.

Just make sure that's portable.. :-)



adrian


More information about the freebsd-hackers mailing list