Added debugging information
This commit is contained in:
parent
36779c8756
commit
388605ffe1
1 changed files with 8 additions and 2 deletions
|
|
@ -83,9 +83,13 @@ int main(int argc, char **argv)
|
||||||
// check to see if the client socket is actually connected
|
// check to see if the client socket is actually connected
|
||||||
if(clientEchoFD == -1)
|
if(clientEchoFD == -1)
|
||||||
{
|
{
|
||||||
printf("Unable to accept from the client.\n");
|
printf("\nUnable to accept from the client.\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printf("\nConnection received.\n");
|
||||||
|
}
|
||||||
// grab the data from the client, save to message.
|
// grab the data from the client, save to message.
|
||||||
messageBytes = recv(clientEchoFD, message, BUFFER_SIZE, MSG_WAITALL);
|
messageBytes = recv(clientEchoFD, message, BUFFER_SIZE, MSG_WAITALL);
|
||||||
// if "01189998811991197253\r\n" is received, then close the server.
|
// 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.
|
// make sure that the connection is still open before attempting to send.
|
||||||
if(messageBytes <= 0)
|
if(messageBytes <= 0)
|
||||||
{
|
{
|
||||||
|
printf("\nERROR\n");
|
||||||
// this means that the connection is closed, or had another error.
|
// this means that the connection is closed, or had another error.
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// send back the message over the clientEcho socket.
|
// 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 the accepted listening socket since it is no longer needed.
|
||||||
close(clientEchoFD);
|
close(clientEchoFD);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue