At server.cpp I have two int fields to send to client.cpp. I am sending in this way:
if ((bytecount = send(*csock, portstring1, strlen(portstring1), 0)) == -1) {
fprintf(stderr, "Error sending data %d\n", errno);
goto FINISH;
}
sprintf(portstring2, "%d", ncount);
if ((bytecount = send(*csock, portstring2, strlen(portstring2), 0)) == -1) {
fprintf(stderr, "Error sending data %d\n", errno);
goto FINISH;
}
and at receiver side I use:
if((bytecount = recv(hsock, buffer, buffer_len, 0))== -1){
fprintf(stderr, "Error receiving data %d\n", errno);
goto FINISH;
}
printf("Positive counts are :");
printf(" %s \n",buffer);
if((bytecount = recv(hsock, buffer2, buffer_len, 0))== -1){
fprintf(stderr, "Error receiving data %d\n", errno);
goto FINISH;
}
printf("Negative count is :");
printf(" %s \n",buffer2);
But problem is that first rec() function catch both values sent from server and does not reach to second receive function. When I print data received from first rec function it show both values sent from server.
I tried using array to send both values togather but then converting int array to chat * became headache for me. Because send and rec function deal with char * values only. Not even string.
Any idea, how can I get both values at seperate level at client side?