WSAEWOULDBLOCK and WSAEISCONN
I wrote this code:
I get this output:
SOCKET sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
//snip - initialize the socket_address' members - snip//
int status = 1;
ioctlsocket(sock, FIONBIO, &status); //set the socket in non-blocking mode
int ret = connect(sock, (sockaddr*)(&socket_address), sizeof(socket_address));
if (ret == -1)
cout << "Connection error : " << WSAGetLastError() << endl;
Sleep(50); //wait a bit to not hang the CPU
cout << "Connection succeeded" << endl;
WSAEWOULDBLOCK - the connect function would block, try again later
WSAEISCONN - the socket is already connected, why are you trying to connect it again?
(ofcourse the output is written in numbers, but I translated the error codes and added my comments on what they mean imho).
So, what's wrong(firt it says: try again later, but later, it says that the socket is already connected)?