Hi,
i am trying to send an ID to a server. The ID is sent more than once during the execution of the program. Each time i need to send the ID the following code is called:
Code:
void CRFIDReaderConsole::SendID(int id)
{
RFIDClient* client = ::new RFIDClient();
BOOL bRetVal;
bRetVal = client->OpenConnection("localhost",6000);
if(bRetVal)
{
if(client->IsConnected())
{
int ClaimedIDFromRFID = id;
char buf[255];
//sprintf(buf,"ClaimedID:=%d",ClaimedIDFromRFID);
CString strMessage = buf;
CNDKMessage message(ChatUserJoin);
message.Add("RFIDReader");
client->SendMessageToServer(message);
CNDKMessage message2(ClaimedID);
message2.Add(strMessage);
client->SendMessageToServer(message2);
client->CloseConnection();
}
}
if(client)
{
delete client;
}
}//SendID
The first time this code is called during the execution, the ID is sent successfully. The second time the program returns a debug error when the "bRetVal = client->OpenConnection("localhost",6000);" statement is called. During doing some debugging and one the second call of the former statement - ie when a second connection was requested, i was pointed to the followed code part of "wincore.cpp" by the debugger, if it is any help:
Code:
if (!::RegisterClass(lpWndClass))
{
TRACE(traceAppMsg, 0, _T("Can't register window class named %s\n"),
lpWndClass->lpszClassName);
return FALSE;
}
any ideas?
Thanks