>>And if I choose to unblock it, and do a WSAAsyncSelect on the used socket, how can I later continue the accept process?
With async sockets, handle the FD_ACCEPT message, ie:
Code:
//set up async server socket
if (WSAAsyncSelect(hSocket, hwnd, WM_WSAASYNC, FD_READ |
FD_ACCEPT | FD_CLOSE)!=0)
{
//handle error
}
sockaddr_in sockAddr = {0};
SetServerSockAddr(&sockAddr, SERVER_PORT);
if (bind(hSocket, reinterpret_cast<sockaddr*>(&sockAddr), sizeof(sockAddr))!=0)
//handle error
if (listen(hSocket, SOMAXCONN)!=0) //set socket to listen for incoming data
//handle error
Code:
//in message loop
case FD_ACCEPT:
if (WSAGETSELECTERROR(lParam))
{
MessageBox(NULL,"error accepting connection","FD_ACCEPT Error",MB_OK);
}
//accept connection
break;