select() question (winsock2).
Hello everyone!
In all tutorials I've read this far select is mainly used with non-blocking sockets. What I'm curious about is if there is something wrong about using select with blocking sockets like this:
Code:
timeval timer = {5, 0}; //wait five sec
fd_set my_set;
FD_ZERO(&my_set);
SOCKET server = socket(AF_INET, SOCK_STREAM, 0);
bind(server,..blah..blah..);
listen(server, 5);
FD_SET(server, &my_set);
if (select(0, &my_set, NULL, NULL, &timer) == 1)
{
SOCKET client = accept(server, ...blah....blah...);
}
else
{
cout << "No connection within timelimit.";
}
This way I can await connections within a timelimit but still use blocking sockets and that's what I want to do, so is there anything bad about using select this way?