pollfds2_count = select (0, readfds, writefds,exceptfds, &twait); From one of the support forums i came to know that select() will return immediately even timeval parameter set to "non zero" or non NULL values. Am i correct? (They mentioned a possible bug in windows).

For our application to work correctly select should wait for THIRTY_MILLISECONDS.

Comments

You seem to have misunderstood the functionality of select. Select [b]does not[/b] wait for the time interval specified. It checks the status of the specified sockets, that is whether the socket has data ready to be read (sockets in readfds), or socket is ready to be written (sockets in writefds) or have errors (exceptfds).The timeout specifies the [b]maximum[/b] time for the status to change.

A sample usage of select is to check if there is data to be read from socket to ensure that read does not block:[code]twait.tv_sec = 0; twait.tv_usec = THIRTY_MILLISECONDS

You seem to have misunderstood the functionality of select. Select [b]does not[/b] wait for the time interval specified. It checks the status of the specified sockets, that is whether the socket has data ready to be read (sockets in readfds), or socket is ready to be written (sockets in writefds) or have errors (exceptfds).The timeout specifies the [b]maximum[/b] time for the status to change.

A sample usage of select is to check if there is data to be read from socket to ensure that read does not block:[code]twait.tv_sec = 0; twait.tv_usec = THIRTY_MILLISECONDS

The sleep() method will work, but it can cause the entire program to sleep, unless it is multithreaded and the network thread is all by itself. The easiest way to avoid blocking is to simply specify the non-blocking style for the socket. This way you can check it a thousand times a second and it won't block.[code]sockfd = socket(PF_INET, SOCK_STREAM, 0);fcntl(sockfd, F_SETFL, O_NONBLOCK);[/code]If you want a GREAT guide on programming sockets (TCP and UDP), check out the link below.