Problems with Sockets and select.

Tim Newsham
Thu Oct 2 13:04:00 GMT 1997

> Hi all,
> This is a follow up to another post I made {with no replies :-( }
> I have an application that does interprocess communication with sockets.
> The main server process does a select to multiplex I/O from the clients.  The
> select call completes, but when I go to read the socket with input pending,
> I block on the read call.  Which is strange, since select says there is input
> ready for that socket.
> This same code works in almost all flavors of Unix that I have tried.
> Any suggestions or work arounds would be helpfull.

In winsock, a read/recv() will block until the full amount
of data requested is available if you aren't in non-blocking
mode.  So if you do read(s, buf, 2), and there is only 1 byte
available, you will block until there are 2.  This is not the
same behavior observed in unix.  You can do an ioctl to determine
the number of bytes actually available after the select (FIONREAD)
and read only that amount, to avoid blocking.

> Rick
> * email:  * The contents of this message in    *
For help on using this list (especially unsubscribing), send a message to
"" with one line of text: "help".

More information about the Cygwin mailing list