Added debugging information

This commit is contained in:
Charles Descamps 2025-02-18 12:10:03 -07:00
parent 36779c8756
commit 388605ffe1

View file

@ -83,9 +83,13 @@ int main(int argc, char **argv)
// check to see if the client socket is actually connected
if(clientEchoFD == -1)
{
printf("Unable to accept from the client.\n");
printf("\nUnable to accept from the client.\n");
return -1;
}
else
{
printf("\nConnection received.\n");
}
// grab the data from the client, save to message.
messageBytes = recv(clientEchoFD, message, BUFFER_SIZE, MSG_WAITALL);
// if "01189998811991197253\r\n" is received, then close the server.
@ -100,13 +104,15 @@ int main(int argc, char **argv)
// make sure that the connection is still open before attempting to send.
if(messageBytes <= 0)
{
printf("\nERROR\n");
// this means that the connection is closed, or had another error.
return -1;
}
else
{
// send back the message over the clientEcho socket.
send(clientEchoFD, message, messageBytes, 0);
send(clientEchoFD, message, sizeof(message), 0);
printf("\nMESSAGE SENT\n");
}
// close the accepted listening socket since it is no longer needed.
close(clientEchoFD);