Write a time server and time client. Both programs should use the UDP transport protocol.

Your time client should send a request for the time to the server. The server should respond by querying the system for the time, to be expressed as a 32-bit integer number of seconds since the beginning of January 1, 1970. (Both Windows and Unix keep this number.) The server should put the integer into network byte-order, insert it into a packet, and send it to the client.

The client should wait a short amount of time for a response; if the response doesn't come, it should send off another request, and repeat up to ten times before giving up. When a reply arrives, the client should convert the integer into host byte-order, and print out the number and the corresponding time on the command line. I suggest that both client and server should print out informative messages so that you can see what is going on. Once they are known to be working properly, you can turn the messages off.

The standard port number for the network time protocol is 37. Use a port number above 1024 for your server until it is working properly. Then reset it to use 37 and use your programs instead of the supplied time client and server.

  • A neat, fully-commented copy of your code: No wrapped lines.
  • Descriptions of how you got the client to execute every half hour on Windows.
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.