-
March 5th, 2009, 07:40 PM
#1
WSA Refusing connection - howto find out the server refused connection?
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:
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;
the WSAECONNREFUSED error never occurs. how it is possible? whats wrong? im sure the server refuse connection.
thanks
-
March 5th, 2009, 07:45 PM
#2
Re: WSA Refusing connection - howto find out the server refused connection?
Perhaps it is occurring at the router frame or some other firewall. Have you tested a traceroute?
ahoodin
To keep the plot moving, that's why.
-
March 6th, 2009, 09:51 AM
#3
Re: WSA Refusing connection - howto find out the server refused connection?
i will try it. its some possibility to fix it? the FD_CONNECT event occurs but WSAECONNREFUSED error not.
-
March 7th, 2009, 05:59 AM
#4
Re: WSA Refusing connection - howto find out the server refused connection?
i cant capture packets in wireshark or ethereal because they cant capture localhost packets. i tried to fix it like this http://wiki.wireshark.org/CaptureSetup/Loopback but it didnt fix it
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|