CIS 457 Lab Assignment 2: UDP Echo Client/Server

Objective: Gain familiarity with UDP (datagram) sockets by writing a simple program.

Deliverables: The source code to your client and server, and a screenshot or copy of the input and output from running them, in hard copy.

Teams: You should write your code individually, although you may of course discuss with classmates.

Programming Languages: It is suggested that you complete this lab assignment in C, although you may use other languages if desired.

Grading: 10 points, as described below.

Example Code:

In this assignment, you are to write an echo server, and a client that interacts with it. An echo server simply sends back to the client the same data that was sent to the server. The program must use UDP (Datagram) sockets, it may not use TCP (Stream) sockets. Specifically your programs must do the following:

  1. When started, the server should ask for a port number. Your server should then listen for connections on that port. (1 point)
  2. When started, the client should ask for an IP address and a port number. Later, when sending a message out, this address and port number should be used as the destination. (2 point)
  3. The client should prompt the user for input. Upon user input, the client should send the input to the server (IP address and port given in the previous step). (2 points)
  4. The server should receive the message from the client, print it out, and sent it back to the client. (2 points)
  5. The client should receive the reply, print it, and exit. (2 points)
  6. The server should always be able to handle a new client, accepting its messages and sending responses to the appropriate place. The server must not close automatically after recieving or sending a message. (1 point)