hello,
I am usning win 98 SE and visual studio 6.0
I wrote a client and a server. I used WSAAsyncSelect() to make recv()
non blocking in both client and server which is working perfectly. In
the server, i was using accept() in a while() loop which is making the
server blocking while listening because as soon as the user clicks
onthe "Listen" button, it enters into the following while loop and
blocks but when i connect using the client, it accepts it perfectly
and works.
// -start-
TempSock = SOCKET_ERROR;
while (TempSock == SOCKET_ERROR)
{
TempSock = accept(Socket, NULL, NULL);
}
Socket = TempSock;
DialogBox(hInst, (LPCTSTR)IDD_CHATBOX, hDlg, (DLGPROC)Chat);
// above dialog box opens up 2 edit controls to send and recv messages
}
// -end-
After this i thought of bringing this accept() out of while loop too
and i used:
WSAAsyncSelect(Socket, hDlg, WM_STARTACCEPT,FD_ACCEPT);
in the starting and used "case WM_STARTACCEPT: " to call the accept()
which is now not in any while loop.Now when i connect using the client
it shows me the error that my socket is not listening, error 10022 . I
dont know whats wrong. Any help will be greatful.
Thanks
Dwij Aggarwal