Assignment 3

Background

Another UNIX utility is the date command. When you type date at the command line, you simply get the current date and time. You can find out more about date by typing

man date

You can also obtain the date and time by using Telnet and the command

telnet triton 13

As you might have guessed, a daytime server is running on port 13; all it does is return the current date and time. The daytime protocol is simple and is described in RFC 867.

Assignment

Write a daytime server DaytimeServer.java according to the RFC 867 protocol. Your server should wait to be contacted. When a client makes a connection, the server returns the current date and time. It then closes the connection and waits to be contacted again.

A daytime server usually runs on port 13, and you should use this as the default. However, running a server on port 13 requires root (superuser) privileges, and so you should allow another port to be specified on the command line when your server is started. For example, to run your daytime server on port 1313, you would type

java DaytimeServer 1313

If no port is specified on the command line, the default port 13 is used.

One technicality. You will need to figure out how to get the current date and time.

Groundrules

See the rules for programming assignments on the main course Webpage. You may work individually or in teams of two or three people.

Submission

As noted on the main course Webpage, assignments are to be submitted electronically as e-mail attachments. Use the address

contst10@cs.gettysburg.edu

The e-mail message itself must contain the Honor Pledge and the full names of the people submitting the assignment. Only one submission should be made for each team.

Due Date and Time

This assignment is due at 12:01 AM on Wednesday, February 14. Late work is not accepted, but early submissions are welcome!