I worked it out. What I did was stored the bytes received in a char pointer, and did the following changes to this function.
Code:
bool RECV_MSG ( SOCKET_DATA* PIPE, char *message, char *RECVD_BYTES ) {
ssize_t status;
status = recv( PIPE->m_sock, message, BUFFER, 0 );
if ( status < 0 ) {
printf ("%c[1;91m - ERROR #%d: Cannot recieve message!%c[0m\n", 27, errno, 27);
return false;
} else if ( status == 0 ) {
printf ("%c[1;95m - WARNING #%d: Could not read from socket, this is OK.%c[0m\n", 27, errno, 27);
return false;
} else {
sprintf( RECVD_BYTES, "%d", ( int ) status ); // This is what I added.
return true;
}
}
bool SEND_MSG ( SOCKET_DATA* PIPE, char *message, char *SEND_BYTES ) {
ssize_t status;
status = send ( PIPE->m_sock, message, atoi ( SEND_BYTES ), 0 );
if (status < 0) {
printf ("%c[1;91m - ERROR #%d: Cannot send message!%c[0m\n", 27, errno, 27);
return false;
} else {
return true;
}
}
I figured I could use an int pointer, but I didnt know how to work that one, so I used a char* instead. I couldn't be happier, it took me a while to figure this one out. As we speak I'm using this program .