The Time Server

Your Goal:  You should have two programs, a client and a server.

The Client:  It should do the following

  1. Create a socket to the server
  2. Read a line from the server
  3. Print the line
The Server:  It should do the following
  1. Create a socket
  2. Wait for the connection
  3. Accept the connetion
  4. Write a line of text down the socket
Points Task
5 (1 each) Correct use of socket, gethostbyname, bind, connect, accept
2 Every variable has a comment describing it's use
-3 Code indented wrong
2 Server makes a socket
2 Client connects to the socket
2 Server sends a line of text
2 That line actually contains the current time
2 Client receives and prints the line of text
3 Server can accept multiple successive connections
2 (1 each) Client or server can accept the port number from the keyboard or the command line
2 Turned in by Tuesday 25th at 4:00pm
-2 Turned in after Thursday 27th at 4:00pm
1 Do correct error checking once
1 more Do correct error checking EVERY time it's needed.
3 Server offers and client can get either the time or the joke-of-the-day, depending on what the user wants
2 Server prints the IP number of the client who's connected.

Hints:  You can get the current time in UNIX format via
time_t ticks = time();
You can convert a UNIX time into a "struct tm" via
struct tm current_tm = localtime(ticks);
You can convert a struct tm into a string via
asctime(current_tm);