WSAEWOULDBLOCK bei connect
-
Hi,
ich bekomm von meinem connect immer -1 zurück und
iError = WSAGetLastError();
liefert 10038 = WSAEWOULDBLOCK...
Was kann man da machen?!? Ist ein einfacher HTTP Server auf Port 8080 zu dem ich mich connecten will...Hier der ganze code:
int WSASetup(HWND hWnd) { WSAStartup(MAKEWORD(2,0),&wsa); s = socket(AF_INET,SOCK_STREAM,0); //int iError; if(SOCKET_ERROR == WSAAsyncSelect(s,hWnd,WM_SOCKET_NOTIFY,FD_READ)) { closesocket(s); WSACleanup(); return WSA_ERROR; } return WSA_OK; } BOOL CALLBACK DlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { int iError; struct hostent* dnsip; switch (message) { case WM_INITDIALOG: //*** WSA Connect ***// if (WSASetup(hDlg) == WSA_ERROR) return 0; memset(&srv, 0, sizeof(SOCKADDR_IN)); if (inet_addr(ip_address) == INADDR_NONE) { dnsip = gethostbyname(ip_address); if (dnsip) memcpy(&srv.sin_addr, dnsip->h_addr_list[0], sizeof(dnsip)); else return 0; } else { srv.sin_addr.s_addr = inet_addr(ip_address); } srv.sin_port = htons(port); srv.sin_family = AF_INET; SetTimer (hDlg, ID_TIMER_CONNECT, 1200, 0); break; return TRUE; case WM_COMMAND: switch (LOWORD (wParam)) { case IDCANCEL: case IDOK: closesocket(s); WSACleanup(); //Schluss mit dem Leben :( EndDialog (hDlg, 0); return TRUE; } break; case WM_TIMER: iError = connect(s,(struct sockaddr*) &srv, sizeof(srv)); if (iError != 0) { iError = WSAGetLastError(); SetWindowText(GetDlgItem (hDlg, IDC_INFO), "OFFLINE"); } else { SetWindowText(GetDlgItem (hDlg, IDC_INFO), "online"); } closesocket(s); WSACleanup(); WSASetup(hDlg); break; } return FALSE ; }
-
ok... lag an der zeile:
if(SOCKET_ERROR == WSAAsyncSelect(s,hWnd,WM_SOCKET_NOTIFY,FD_READ))
-
Noch als Anmerkung:
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).
[...]
WSAEWOULDBLOCK - The socket is marked as nonblocking and the connection cannot be completed immediately.