I'm having a problem with my connection. When I connect to a battle.net Server everything is fine, but if i am IPBanned when i try to connect the Program just exits. Here's a step by step:
When the user clicks file->Connect A thread is created for the Recieving from the Socket.
case WM_COMMAND:
switch(LOWORD(wParam))
{
case FILE_CONNECT: //CONNECT EVENT
{
Addchat("Attempting to Connect to Battle.net");
threadHwnd = CreateThread(NULL,0,&ThreadProc,(LPVOID)SOCKET_RECIEVE,0,NULL);
}
Now in the ThreadProc. I create the Socket, Connect to battle.net, If successful I send 0x50 then Enter the Recieving Loop Like So:
case SOCKET_RECIEVE:
WORD sckVersion;
WSADATA wsData;
sckVersion = MAKEWORD(1,1);
WSAStartup(sckVersion,&wsData);
LPHOSTENT hostData;
in_addr ipHost;
hostData = gethostbyaddr((const char *)&ipHost, sizeof(struct in_addr), AF_INET);
wSock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
SOCKADDR_IN hostInfo;
hostInfo.sin_family = AF_INET;
hostInfo.sin_addr.s_addr = inet_addr("63.240.202.120");
/* Ip's
useast = 63.240.202.120
asia = 211.233.0.80
europe = 213.248.106.65
*/
hostInfo.sin_port = htons(6112);
if(connect(wSock,(LPSOCKADDR)&hostInfo,sizeof(SOCKADDR_IN)) != SOCKET_ERROR)
{
Addchat("Connected to Battle.net!");
Addchat("Sending 0x50...");
buffer pBuffer;
pBuffer.InsertDWORD(0);
pBuffer.InsertNonNTString( "68XIPXES" );
pBuffer.InsertDWORD( 0xCD );
pBuffer.InsertDWORD(0);
pBuffer.InsertDWORD(0);
pBuffer.InsertDWORD(0);
pBuffer.InsertDWORD(0);
pBuffer.InsertDWORD(0);
pBuffer.InsertNTString("USA");
pBuffer.InsertNTString("United States");
pBuffer.SendBNCSPacket(wSock,0x50);
long nret = 1;
char rBuffer[255];
while(nret != SOCKET_ERROR && nret != 0)
{
nret = recv(wSock,rBuffer,255,0);
char InData[nret];
CopyMemory(InData,rBuffer,nret);
Parsep(InData,nret);
}
}
else
{
Addchat("Error connecting to Battle.net!");
}
break;
Is there Anyway to catch this? This event only happens when I am IPBanned from the server before I Connect, if im not the Connection and packet sequence goes on normally. Is there some kind of Error Handling I need to implement? Or am I going about this in the wrong way?
Spilled[DW]