While porting unix C++ code under windows and using sockets/winsock API, I am confronted with this on the server side:
recv(ClientSocket, recvbuf, recvbuflen, MSG_DONTWAIT); // UNIX code
I found from here that the equivalent of the MSG_DONTWAIT flag with WSA is to set the socket in nonblocking mode with ioctlsocket
: call FIONBIO with arg != 0 (here is the documentation).
Being on the server side, I have though two sockets:
The socket for connecting to server:
SOCKET ListenSocket = socket(...) bind(ListenSocket, ...) listen(ListenSocket, ...) ...
The temporary socket for accepting connections from clients:
SOCKET ClientSocket; ClientSocket = accept(ListenSocket, ...) recv(ClientSocket, ...) ...
Which socket do I call ioctlsocket
with? And where? (I mean where wrt these steps?)