Jump to content
  • Advertisement
Sign in to follow this  
Aileen

cannot get this work

This topic is 4251 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am writing the following code to set the socket to asynchronous mode: "if (!WSAAsyncSelect (ConnectSocket,DXUTGetHWND(),WM_ONSOCKET,(FD_READ | FD_CONNECT | FD_CLOSE))) { Printf( "set asynchronous mode fail, error code: %d", WSAGetLastError() ); } " I think I called the function correctly. But I just couldn't get it work. So I call WSAGetLastError() to see what went wrong. on the description of the function: http://msdn2.microsoft.com/en-us/library/ms741540.aspx It says that I can retrieved the error code by calling WSAGetLastError(). I did it, but the return value is '0', which cannot be found in the error code list. Btw, I have initialized the socket ConnectSocket by "ConnectSocket = socket(ptr->ai_family, ptr->ai_socktype, ptr->ai_protocol);" Could someone help me pls? Thanks a lot.

Share this post


Link to post
Share on other sites
Advertisement
"If the WSAAsyncSelect function succeeds, the return value is zero. Otherwise, the value SOCKET_ERROR is returned".

Your if-statement is therefore backwards.

Share this post


Link to post
Share on other sites
Quote:
Original post by Kylotan
"If the WSAAsyncSelect function succeeds, the return value is zero. Otherwise, the value SOCKET_ERROR is returned".

Your if-statement is therefore backwards.


My bad!
I got the output "set asynchronous mode fail, error code: 0". This means the WSAAsyncSelect function succeeds. :)

Thanks~!

Share this post


Link to post
Share on other sites
You'll find that in almost all cases where a function uses an integer return value to indicate success that 0 will mean success. The theory is that there might be lots of different things that went wrong that the function might want to tell you about, but generally only one type of success.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!