finished homework one, testing complete?
This commit is contained in:
parent
46b87dff01
commit
e1eefb9fd4
1 changed files with 2 additions and 5 deletions
|
|
@ -46,17 +46,14 @@ int main(int argc, char **argv)
|
||||||
message[receivedDataLen] = '\0';
|
message[receivedDataLen] = '\0';
|
||||||
printf("Message rec: %s", message);
|
printf("Message rec: %s", message);
|
||||||
// if "time\r\n" is received, then send() back the linux epoch.
|
// if "time\r\n" is received, then send() back the linux epoch.
|
||||||
if(strcmp(message, "time\n") == 0)
|
if(strcmp(message, "time\r\n") == 0)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
char reply[BUFFER_SIZE];
|
char reply[BUFFER_SIZE];
|
||||||
sprintf(reply, "%d", time(NULL));
|
sprintf(reply, "%d", time(NULL));
|
||||||
printf("%s", reply);
|
|
||||||
// char *reply = time(NULL);
|
|
||||||
// char *reply = "Replied";
|
|
||||||
sendto(socketTimeFD, (const char *)reply, strlen(reply), 0, (const struct sockaddr *) &clientAddr, clientAddrLen);
|
sendto(socketTimeFD, (const char *)reply, strlen(reply), 0, (const struct sockaddr *) &clientAddr, clientAddrLen);
|
||||||
}
|
}
|
||||||
else if(strcmp(message, "close") == 0 || strcmp(message, "quit") == 0 || strcmp(message, "q") == 0)
|
else if (strcmp(message, "close\n") == 0 || strcmp(message, "quit\n") == 0 || strcmp(message, "q\n") == 0)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
printf("\nServer received close.\n");
|
printf("\nServer received close.\n");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue