-
Re: CAsyncSocket????????
Hi Vicken
The return value of 10035 is WSAEWOULDBLOCK. The result is simply saying that this call will cause a blocking action to take place. If you think about it, that's true. Until the connection is made, the connect function will block. The result codes are in winsock.h in the include directory of VC. OK, now you know why connect is 'failing', so Look up 'Connect' in the online help. Connect for the platform SDK, not the socket classes, because the classes are based on the raw socket functions.
Here is a partial listing from the help file...
On a blocking socket, the return value indicates success or failure of the connection attempt. With a nonblocking socket, the connection attempt cannot be completed immediately. In this case, connect will return SOCKET_ERROR, and WSAGetLastError will return WSAEWOULDBLOCK. In this case, there are three possible scenarios:
Use the select function to determine the completion of the connection request by checking to see if the socket is writeable.
If the application is using WSAAsyncSelect to indicate interest in connection events, then the application will receive an FD_CONNECT notification indicating that the connect operation is complete (successfully or not).
If the application is using WSAEventSelect to indicate interest in connection events, then the associated event object will be signaled indicating that the connect operation is complete (successfully or not).
I would use the WSAAsyncSelect function to get a message when the socket has actually connected. It's better to be notified when the connection happens than to have you application 'lock up' while waiting for it...this is the Windows Way. In the socket classes, WSAAsyncSelect is called AsyncSelect.
Regards,
Paul Belikian
-
Re: CAsyncSocket????????
In create you specify all the options like
FD_READ | FD_WRITE | FD_ACCEPT | FD_CONNECT | FD_CLOSE | FD_CONNECT
also check whether that port is in use by any other program.
after listen you need call accept continously to accept client connections.
in the code you have given it seems you are not using it.
-
Re: CAsyncSocket????????
Getting 0 from your Connect is a good sign - that means it succeeded!