Jump to content
  • Advertisement
Sign in to follow this  
DT2K

Connect function question

This topic is 4885 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 have a rather strange problem that despite my best efforts, cannot solve. The connect function of Winsock 2.2 seems to like destroying my window. I have debugged it to the point where I have determined that it is the execution of this one line that infact causes the window to close and WM_DESTROY to be activated. Here is the entire code in the function, which (what seems to me) randomly stopped working after having worked perfectly for a long time. sockaddr_in target; g_App.c = socket (AF_INET, SOCK_STREAM, 0); // Create socket if (g_App.c == INVALID_SOCKET) MessageBox(g_App.GetWindowHandle(),"WINSOCK CLIENT ERROR1",NULL,0); WSAAsyncSelect(g_App.c, g_App.GetWindowHandle(), WM_WSAASYNC, FD_WRITE | FD_CONNECT | FD_READ | FD_CLOSE); target.sin_family = AF_INET; // address family Internet target.sin_port = htons (5555); // set server’s port number target.sin_addr.s_addr = inet_addr ("127.0.0.1"); // set server’s IP //this line below breaks my window connect(g_App.c, (LPSOCKADDR)&target, sizeof(target)); As I said, this is the entire SetUpWinsock() Function that I made and it had worked perfectly for a long time. The question is, what type of an error causes the connect function to crash the current window?

Share this post


Link to post
Share on other sites
Advertisement
Regretably, the return value is 0, meaning it works fine, what gets me is that the connect function triggers the DestroyWindow command. Any ideas as to what causes the spontaneous closing of windows?

Share this post


Link to post
Share on other sites
No no, its mapped as WM_USER + 5. As I mentioned before, the program used to work perfectly until recently.

Share this post


Link to post
Share on other sites
well, it's obviously not connect() causing any windows to be closed.

What it *does* do is trigger a message. You should check the messages your window is receiving with spy++ and track it down that way.

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!