0

Hi to all,

In my little server program, I have this code:

i=0;
       charRecv = recv(nSocketDesc, &c, 1, 0);
       while (c !='\n')
       {
        mystring[i++]=c;
        charRecv = recv(nSocketDesc, &c, 1, 0); 
       } // End while (c !='\n') 
       mystring[i]='\0';

'c' are a sequence of char sended to server from a client and stored in mystring.
The 'while' must be ended, when the client press enter.
But my 'while' continue the loop. Sure, i mistake something.:sad:
Please can You help me in order to resolve this problem ?

Best Regards
Nick

2
Contributors
1
Reply
2
Views
11 Years
Discussion Span
Last Post by Ancient Dragon
0

check the client to see if it is sending the '\n' character. maybe it just terminates and doesn't send it. Also, your server program should check for buffer overflow before adding a new character. Terminate the loop if the buffer fills up.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.