CIS 457 Lab Assignment 6: UDP Simple Chat

Objective: Gain familiarity with selectors by writing a simple program.

Deliverables: The source code to your client and server, in hard copy.

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

Grading: 10 points, as described below.

Sample code:

In this assignment, you are to write a server and a client that interacts with it. The server only needs to handle one client at a time. Datagram sockets (UDP) must be used. Each of the server and client must be able to send messages to each other and recieve messages from each other in any order. You must not use socket timeouts. You must accomplish this by using select.

  1. When started, the server should ask for a port number. Your server should then listen for connections on that port. When started, the client should ask for an IP address and a port number. The client should send a message to the server on the given IP address and port, in order to notifiy the server that the client is there. (1 point)
  2. After the client has contacted the server, both the client and server should prompt the user for input. (1 point)
  3. Upon user input, the client should send the input to the server. Similarly, upon user input the server should send the input to the client. (1 points)
  4. When the server or client gets a message, it should immediately print the message. This may cause it to print in the middle of someone typing on the other end. This is not considred a problem for this assignment. (1 point)
  5. Both the server and client must continue to accept input and messages on their sockets so that multiple messages can be sent. Messages must be able to be sent in both directions, in any order. (4 points)
  6. If "Quit" is typed at the message prompt, instead of sending the message, the server or client should exit, after notifying the other side of the connection, which should also exit. (2 points)