You must better understand the send process. You send single bytes (by accessing an char array, so a string is a char array and it works out of the box. But for sending an int you must copy integer into byte array with a terminating zero.
char buffer[5] = {0};memcpy( buffer, &intValue, 0);
and send that buffer. On the receiver side you must reversly copy the buffer into an integer.