nonblocking socket (winsock)
Hi
Ive been searching the msdn for a long time and cant find information about setting a socket to nonblocking.
You can use ioctlsocket() with an FIONBIO arguement to set a socket to non blocking. Also with Winsock a call to WSAAsyncSelect() or WSAEventSelect() will set a socket to non-blocking mode.
so if I want to make socket s nonblocket I use this line?
WSAEventSelect(s,0,0);
?
WSAEventSelect(s,0,0);
?
how about using
ioctlsocket(sIncomingConnection,FIONBIO,1);
I dont understand what the parameter 3 is for. Msdn say that it should be a non zero when FIONBIO is to be used. But what should I but there. I just want to set socket s to nonblocking.
ioctlsocket(sIncomingConnection,FIONBIO,1);
I dont understand what the parameter 3 is for. Msdn say that it should be a non zero when FIONBIO is to be used. But what should I but there. I just want to set socket s to nonblocking.
This seems to work, but there is one problem. Recv and send return -1 (SOCKET_ERROR) so how do i know if the clientprogram just closed down the program without disconnecting.
If clientprogram disconnect i get 0 in return from recv and send.
If clientprogram disconnect i get 0 in return from recv and send.
use WSAGetLastError() to determine the exact error for the send() and recv() calls.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement