CIS 457 Lab Assignment 3: Simple calculator client/server


Objective: Gain familiarity with manupulation packet data and methods to send non-character data over the network.

Deliverables: The source code to your client and server, and a screenshot or copy of the input and output from running them on Mininet, 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.


In this assignment, you are to write an calculator server and a client that interacts with it. The calculator client should send two integers to the server. These integers should be sent in the same packet as each other, and placed in the packet directly (using memcpy or other similar method), not converted to text. The server should add them up, and send back the result (as an integer, not converted to text). If overflow occurs, it should instead send back some indication of the errror. 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 client should ask for the IP address of the server. The client and server may each ask for the server's port number or you may hard code it. Later, when sending a message out, this address and port number should be used as the destination. (2 points)
  2. The client should prompt the user for two integers of input. Upon user input, the client should send the input to the server. The client may not convert these to text before sending. (2 points)
  3. The server should receive the integers from the client, add them together, and send the result back to the client if it is valid. (2 points)
  4. If the result is an overflow, the server should send back an error message. The client must be able to distinguish this message from any valid result. (2 points)
  5. The client should interperit the response from the server and print the result or error as appropriate. (1 point)
  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)