Code:
if (FD_ISSET(i, &read_fds))
{ // we got one!!
if (i == STDIN_FILENO) /* Check keyboard */
{
/*fputs(identifier, stdout);*/
fgets(msg, sizeof msg, stdin);
/*send(sockfd, newLine, strlen(newLine), 0);
send(sockfd, identifier, strlen(identifier), 0);*/
int count = send(sockfd, msg, strlen(msg), 0);
msg[count] = '\0';
}
else if (i == sockfd)
{
int count = recv(sockfd, buf, sizeof buf -1, 0);
printf("%s", buf);
buf[count] = '\0';
}
}
This code isn't working. It is an extract from my client.c file.
The first message works fine but subsequent messages, if shorter, will show the latter part of the previous message on the line below. I added a line to print out everytime recv was called and confirmed it was only once, so the problem is elsewhere
Anyone any suggestions?
Thanks