hi, im refusing connection by server, if the client is on the black list. but i cant find out (in the client code), the serve refused.
the client code is:
the WSAECONNREFUSED error never occurs. how it is possible? whats wrong? im sure the server refuse connection.Code:struct sockaddr_in ServerAddress; SOCKET Socket = WSASocket(AF_INET, SOCK_STREAM, IPPROTO_TCP, NULL, 0, WSA_FLAG_OVERLAPPED); if (INVALID_SOCKET == Socket) { ErrorExit("WSASocket error", WSAGetLastError()); return SOCKET_ERROR; //error } WSAEVENT eevent = WSACreateEvent(); WSAEventSelect(Socket, eevent, FD_CONNECT); ZeroMemory((char *) &ServerAddress, sizeof(ServerAddress)); ServerAddress.sin_family = AF_INET; ServerAddress.sin_addr.S_un.S_addr = ulIp; ServerAddress.sin_port = htons(nPortNo); if (SOCKET_ERROR == WSAConnect(Socket, reinterpret_cast<const struct sockaddr *>(&ServerAddress),sizeof(ServerAddress), NULL, NULL, NULL, NULL)) { int iErrCode = WSAGetLastError(); if(iErrCode != WSAEWOULDBLOCK) { closesocket(Socket); ErrorExit("WSAConnect error", iErrCode); return SOCKET_ERROR; //error } } DWORD retCode = WSAWaitForMultipleEvents(1, &eevent, TRUE, INFINITE, FALSE); WSANETWORKEVENTS NetworkEvents; if((retCode != WSA_WAIT_FAILED) && (retCode != WSA_WAIT_TIMEOUT)) { if(WSAEnumNetworkEvents(Socket, eevent, &NetworkEvents) == SOCKET_ERROR) { int iErrCode = WSAGetLastError(); } if((NetworkEvents.lNetworkEvents & FD_CONNECT ) == FD_CONNECT) { int iErrCode = WSAGetLastError(); if(iErrCode == WSAECONNREFUSED) { ErrorExit("Server refuse!", iErrCode); return SOCKET_ERROR; } } } return Socket;
thanks


Reply With Quote


Bookmarks