JJe
2004-08-12 06:41:05 UTC
Hello group
My application works with a number of TCP connections which are handled
in a loop using the select() function. Eventually (very rarely in fact)
my application hangs in an endless loop. The reason is that the select
function starts returning errors 10038 (An operation was attempted on
something that is not a socket.).
I was sure all the sockets were correct nevertheless I added a debug
code to my application to be able to locate the socket that causes the
error. Here is the application in pseudo code:
void mainloop()
{
.
.
.
fd_set rset, wset, eset;
FD_ZERO(&rset);
FD_ZERO(&wset);
FD_ZERO(&eset);
for (all my sockets)
FD_SET(socket, (appropriate set));
error = select(sockmax, &rset, &wset, &eset, &to);
if (error == SOCKET_ERROR && GetLastError() == 10038)
debug10038();
.
.
.
}
void debug10038()
{
for (all my sockets) {
fd_set rset, wset, eset;
FD_ZERO(&rset);
FD_ZERO(&wset);
FD_ZERO(&eset);
FD_SET(socket, &rset);
FD_SET(socket, &wset);
FD_SET(socket, &eset);
error = select(sockmax, &rset, &wset, &eset, &to);
if (error == SOCKET_ERROR && GetLastError() == 10038) {
printf("Invalid socket found!\n");
assert(0);
}
}
}
To my surprise however, all the sockets were really correct. The
debug10038() function always finishes without indicating a socket being
illegal.
Can somebody tell me why select() could be returning error 10038 even
though its parameters are correct? Thank you.
JJ.
My application works with a number of TCP connections which are handled
in a loop using the select() function. Eventually (very rarely in fact)
my application hangs in an endless loop. The reason is that the select
function starts returning errors 10038 (An operation was attempted on
something that is not a socket.).
I was sure all the sockets were correct nevertheless I added a debug
code to my application to be able to locate the socket that causes the
error. Here is the application in pseudo code:
void mainloop()
{
.
.
.
fd_set rset, wset, eset;
FD_ZERO(&rset);
FD_ZERO(&wset);
FD_ZERO(&eset);
for (all my sockets)
FD_SET(socket, (appropriate set));
error = select(sockmax, &rset, &wset, &eset, &to);
if (error == SOCKET_ERROR && GetLastError() == 10038)
debug10038();
.
.
.
}
void debug10038()
{
for (all my sockets) {
fd_set rset, wset, eset;
FD_ZERO(&rset);
FD_ZERO(&wset);
FD_ZERO(&eset);
FD_SET(socket, &rset);
FD_SET(socket, &wset);
FD_SET(socket, &eset);
error = select(sockmax, &rset, &wset, &eset, &to);
if (error == SOCKET_ERROR && GetLastError() == 10038) {
printf("Invalid socket found!\n");
assert(0);
}
}
}
To my surprise however, all the sockets were really correct. The
debug10038() function always finishes without indicating a socket being
illegal.
Can somebody tell me why select() could be returning error 10038 even
though its parameters are correct? Thank you.
JJ.