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

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.