Thread: weird problem with code, not displaying what it should

  1. #1
    Registered User
    Join Date
    May 2002
    Posts
    84

    weird problem with code, not displaying what it should

    ok doing a chat client, and i am having a problem with the receive part of my client. what i receive from the server won't display on the screen, and i can't work out why

    Code:
    	for (;;)
    	{	
    		cin >> sendBuffer;
    	
    
    		if (strcmp(sendBuffer, "quit") == 0) 
    		{
    			stopClient(mysocket);
    			system("cls");
    		
    		}
    
    		
    		if (strcmp(sendBuffer, "help") == 0)
    		{
    			cout<<"Commands List"<<endl;
    			cout<<"quit = exit to main screen"<<endl;
    		}
    		else
    		{
    			
    					
    
    			send(mysocket, sendBuffer, strlen(sendBuffer), 0);
    			
    			while (nbytesrecv == SOCKET_ERROR)
    			{
    				nbytesrecv = recv(mysocket, receiveBuffer, 256, 0);
    				if (nbytesrecv == 0 || nbytesrecv == WSAECONNRESET)
    				{
    					cout << "Connection Closed" << endl;
    					break;
    				}
    				if (nbytesrecv < 0)
    					return;
    				cout << " " << receiveBuffer << endl;
    				}
    			}
    	}

  2. #2
    Registered User
    Join Date
    Aug 2003
    Posts
    1,218
    are you sure nbytesrecv is more than 0??? What do you initialize nbytesrecv with??

  3. #3
    Registered User
    Join Date
    May 2002
    Posts
    84
    dosen't matter, problem sorted now

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 02:51 PM
  2. Weird code execution order problem
    By Syko in forum C Programming
    Replies: 2
    Last Post: 05-12-2005, 02:29 PM
  3. Problem using java programs within C code
    By lemania in forum Linux Programming
    Replies: 1
    Last Post: 05-08-2005, 02:02 AM
  4. Input File HELP, weird problem
    By gravity-1 in forum C++ Programming
    Replies: 5
    Last Post: 03-29-2005, 08:43 PM
  5. Replies: 5
    Last Post: 12-03-2003, 05:47 PM