Tech Journal Back to Tech Journal

Why does select() keep hanging in Linux and not in Windows?

The first int param in the call to select has different meaning depending on the platform. In UNIX/BSD it is the highest FD (filedescriptor) +1 (plus 1. this is important) to check.

So that if you've got a bunch of FDs: serversocket, client1socket, client2socket... etc, you'd need to provide the HIGHEST one (they are just int's after all) as the first paramater to select(). [If you think about it for a moment, this is a lot simpler than it sound. Keeping track of the highest, that is.]

In Windows, the first int param to select() is just a placeholder to stay compatible with the BERKLEY API.

Last updated on 2004-10-29 15:00:00 -0700, by Shalom Craimer

Back to Tech Journal