Archived

This topic is now archived and is closed to further replies.

JMing

Asyconous socket on Winsock2

Recommended Posts

JMing    122
i can create CreateSocket( Socket for request connect ) in not useAsynconous !!BUT when i use Asyconous it error. Error on my server is 10038 (WSAENOTSOCK).!! what can i do??? int G3DSock::CreateClient(char *IP) { sockaddr_in Target; CSocket = socket( AF_INET, SOCK_STREAM, 0 ); //////This Line//////// WSAAsyncSelect(CSocket, App->m_hWnd, WM_CSOCKET, (FD_CLOSE|FD_READ|FD_CONNECT)); /////////////////////////////// Target.sin_family = AF_INET; Target.sin_port = htons (5555); Target.sin_addr.s_addr = inet_addr(IP); //request to connect if( connect(CSocket, (sockaddr*)&Target, sizeof(Target)) == SOCKET_ERROR) { if (WSAGetLastError()==WSAEWOULDBLOCK) { Sleep(750); connect(CSocket, (LPSOCKADDR)&Target, sizeof(Target) ); return 1; } sprintf(App->SockBuffer,"Error: %d",WSAGetLastError() ); MessageBox(App->m_hWnd,App->SockBuffer,"Error", MB_OK); WSACleanup (); geEngine_Printf(App->Engine,300,300,"Can not connect"); return 1; } return 0; }

Share this post


Link to post
Share on other sites