From: Rehmet on
Hi Joe,

Thank you so much for your article in your website.

I have another question regarding socket, will CAsyncSocket good
enough or should I use WinSock? What are advantages and disadvantages
of both?

Thank you.

Regards,
Rehmet

On Mar 24, 8:09 am, Joseph M. Newcomer <newco...(a)flounder.com> wrote:
> That's expected. You changed to use CAsyncSocket, but retained the defective code that
> relies on synchronous behavior. Connect will almost CERTAINLY return FALSE, and when it
> does, if you use WSAGetLastError (a.k.a. ::GetLastError) it will tell you WSA_EWOULDBLOCK,
> which means it is off doing the connect, and it will get back to you when the connect has
> finished doing whatever it does. You should disable the Connect window. Then in your
> OnConnect handler, you will see if the connection succeeded or failed, and if it failed,
> you will take appropriate action (such as re-enabling the Connect window); if it
> succeeeded, you will enable the Disconnect window.
>
> Note that Send, Receive, and so on will also potentially fail with WSAEWOULDBLOCK. You
> would handle those in the OnSend and OnReceive handlers.
>
> See my essay on asynchronous sockets on my MVP Tips site.
> joe
>
>
>