Hi,
I a my server program I have in the main this code:
Code:
int main(int argc, char *argv[])
{
char ctrl_terminator[3];
char terminator[3]={'.','.','\n'};
char msg[BUFLEN];
/* Other variables and the header of main */
while (ctrl_terminator != terminator)
{
i=0;
char_recv = recv(newsocketfd, &c, 1, 0);
while (c !='\n')
{
msg[i++]=c;
char_recv = recv(newsocketfd, &c, 1, 0);
} /* End while (c !='\n') */
msg[i]='\0';
printf("This message is arrived: %s\n",msg);
if (i > 2)
{
strncpy(ctrl_terminator, &msg[i-3], 2);
ctrl_terminator[3] = '\0';
} /* End if */
} /* while (ctrl_terminator != terminator) */
/* The rest of Main */
The program work fine; when the telnet establish a connection with server, I can send to server many msg. But if I close my last message with the sequence "..", the while (ctrl_terminator != terminator) is not verified and I don't can exit from loop.
Sure, I mistake something; but I don't know how to resolve the problem .
Can You help me ?
Best Regards
Nick