Connect function question

Started by
5 comments, last by nevernomore 18 years, 10 months ago
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?
Advertisement
What is your return code on WSAAsyncSelect?
I think trouble not in these codes, but other.
no pains, no gains
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?
maybe you mapped WM_WSAASYNC to WM_CLOSE or some such windows message instead of WM_USER +n ?
No no, its mapped as WM_USER + 5. As I mentioned before, the program used to work perfectly until recently.
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.

This topic is closed to new replies.

Advertisement