debug error on opening network connection

This is a discussion on debug error on opening network connection within the Windows Programming forums, part of the Platform Specific Boards category; Hi, i am trying to send an ID to a server. The ID is sent more than once during the ...

  1. #1
    Registered User
    Join Date
    Dec 2007
    Posts
    19

    debug error on opening network connection

    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
    Last edited by nocturna_gr; 01-21-2008 at 05:28 PM.

  2. #2
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,859
    Often if a method succeeds on the first call, but fails on the next call, it is due to uninitialised variables. In debug mode many IDEs set the variables to 0/NULL. In release mode this does not happen.

    Code:
    char szBuf[256]={0};//set to empty
    Not enough code posted to make any better guess.....


    Could be some memory failure/over-run in your CNDKMessage class. It could be an error with your globals etc.

    Why send in an ID number and then use two diff globals?

    Is the IDE reporting any exceptions/access violations?
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  3. #3
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,484
    You cannot register the same window class name twice.
    It means the code that does this thing should be executed only once in a program.
    Probably your RFIDClient suposed to be one per system
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. losing network connection
    By Elkvis in forum Tech Board
    Replies: 0
    Last Post: 11-19-2008, 11:45 AM
  2. Opening a telnet or SSH connection
    By ac251404 in forum C++ Programming
    Replies: 2
    Last Post: 04-11-2007, 09:17 AM
  3. Headers that use each other
    By nickname_changed in forum C++ Programming
    Replies: 7
    Last Post: 10-03-2003, 04:25 AM
  4. Determining status of a network connection?
    By Cat in forum Windows Programming
    Replies: 0
    Last Post: 06-04-2003, 05:30 PM
  5. Opening programs through a network
    By canine in forum Windows Programming
    Replies: 2
    Last Post: 11-22-2001, 10:12 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21