Non-blocking accept sockets

This topic is 3975 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

Hi, I am working on some network code and I got non-blocking sockets to do non-blocking recv calls via the ioctlsocket method, but when I try to do that on the server socket, the accept() method still blocks.
u_long iMode = 1;
ioctlsocket(server, FIONBIO, &iMode);

I also do that to all the sockets representing clients. Thanks in advanced.

Share on other sites
Are you sure the call to ioctlsocket is succeeding, i.e. no error result? When are you setting FIONBIO in relation to your socket and listen and accept calls?

Share on other sites
Quote:
 Original post by ApochPiQAre you sure the call to ioctlsocket is succeeding, i.e. no error result? When are you setting FIONBIO in relation to your socket and listen and accept calls?

Well, not entirely - I am doing it the same way I'm doing it to all othersockets, and they succeed, but I guess its possible that in the same function, some sockets succeed and some dont?

I'm going crazy!

Edit, should I make a while loop something like:

while(!ioctlsocket(...));

I think they ARE failing.. its supposed to return 0, but when I do a while != 0, it goes on forever.. for all sockets.

This is weird because the recv() calls are non-blocking..

I think I got it to work, thanks Apoch, you were right. I dont understanbd how they failed but still made recv() calls non-blocking