From 388605ffe10797ff5552c65b2626a37547769065 Mon Sep 17 00:00:00 2001 From: cdez Date: Tue, 18 Feb 2025 12:10:03 -0700 Subject: [PATCH] Added debugging information --- echoserver/echoserver.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/echoserver/echoserver.c b/echoserver/echoserver.c index a4ad02d..81cd0d9 100644 --- a/echoserver/echoserver.c +++ b/echoserver/echoserver.c @@ -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);