Thread: debug error on opening network connection

  1. #1
    Registered User
    Join Date
    Dec 2007

    debug error on opening network connection

    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:
    void CRFIDReaderConsole::SendID(int id)
    	RFIDClient* client = ::new RFIDClient();  
    	BOOL bRetVal;
    	bRetVal = client->OpenConnection("localhost",6000);
    			int ClaimedIDFromRFID = id;
    			char buf[255];
    			CString strMessage = buf;
    			CNDKMessage message(ChatUserJoin);
    			CNDKMessage message2(ClaimedID);					
    		delete client;
    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:
    	if (!::RegisterClass(lpWndClass))
    		TRACE(traceAppMsg, 0, _T("Can't register window class named %s\n"),
    		return FALSE;
    any ideas?
    Last edited by nocturna_gr; 01-21-2008 at 06:28 PM.

  2. #2
    train spotter
    Join Date
    Aug 2001
    near a computer
    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.

    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
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Rishon LeZion, Israel
    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
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    David J. Wheeler

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, 12:45 PM
  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, 11:12 PM