// Variables
fd_set s;
SOCKET sock;
TIMEVAL timeout;
// Set Timeout
timeout.tv_sec = 0;
timeout.tv_usec = 100;
// Set the fd_ shizzlenit
FD_ZERO(&s);
FD_SET(sock,&s);
// Call select
select(0,&s,NULL,NULL,&timeout);
if( FD_ISSET(sock,&s) )
{
// Read from socket
}
select() question
There is something that I cannot find in MSDN about select(). When the function returns, how do I know which sockets are readable\writeable? Are the fd_set things changed so that only the readable\writeable ones are still in the fd_set structures?
i.e.
when select() returns, it modifys the set so that only those with readable/writable/errors are contained in there respective sets.
So in your example, s would have only the sockets with waiting data on them.
So in your example, s would have only the sockets with waiting data on them.
Michael BartmanCEO, Lead ProgrammerDark Omen Studios
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement