New version page

UConn CSE 2102 - Lab 7

Documents in this Course
Load more
Upgrade to remove ads

This preview shows page 1 out of 2 pages.

View Full Document
Premium Document
Do you want full access? Go Premium and unlock all 2 pages.
Access to all documents
Download any document
Ad free experience

Upgrade to remove ads
Unformatted text preview:

CSE 3100 Systems Programming Fall 2018Lab #7Welcome to Lab 7! This lab assignment is due 36 hours after your lab session starts. For example,if your lab session starts at 8am on Friday, the assignment is due at 8pm on Saturday.Read each question carefully before beginning work. Start by executing git pull inside your Git repos-itory on the virtual machine. Remember to add, commit, and push when you complete your work. AddONLY *.c to the git repo. Do not add .o files or executables.(100 Points) Sum serverImplement a server program that communicates with a client program via the Internet sockets. Theserver listens on TCP port 3100 and has an IPv4 address. The server computes the sum of integers it receivesfrom the client. The protocol is described below in detail.ProtocolThe messages exchanged between the client and server are lines. Every line must end with a newlinecharacter ('\n'). A line has at most 30 characters, including the newline character. The lines end with anewline character and the NUL character should not be sent. Integers are sent as strings that represent thevalues in decimal. For example, 3100 is sent as four characters "3100".A session starts when a client is connected to the server. When the connection is made, the server sends0, the initial value of the sum, to the client. Specifically, the message the client receives is "0\n". Theclient sends one integer at a time to the server and, in response, the server sends back the sum of all theintegers it has received from the client in the session so far, or an error message if the client does not followthe protocol. To complete the session, the client sends "exit" to the server, and the server responds with"Bye " followed by the sum.Both the server and the client end the session if there is an error reading from/writing to the socket. Theserver should detect errors in the client’s message. The error messages the server should send back to theclient are as follows.1. "Error LongLine " followed by the current sum, if the line is too long.2. "Error NaN " followed by the current sum, if the server fails to find an integer from the line.ImplementationThe server should listen for inbound requests to TCP port 3100 on localhost. It should be able tocommunicate with multiple clients at the same time. Upon receiving a request from a client, the serverspawns a child process responsible for working with the client. Children processes are not overlaid withanother executable. The parent process should reap the dead children processes regularly.The server can rely on sscanf() to read an integer from the line it receives. Check the return valueof sscanf()! The server should allow white spaces at the beginning of lines and extra characters after theinteger. The server should use an integer of int type to keep track of the sum and should ignore overflow.The client gets input lines from stdin and displays the server’s response for each line to stdout. It cancheck if the user input is valid, but does not have to. The client can assume that the server’s response isa single line. If the line is too long, the client can display to stdout the complete line or only the first 30characters.Use the following commands to check process status and terminate processes if necessary: ps, kill, orpkill.Before you complete the client program, use nc localhost 3100 command to test your server. A samplesession is shown below. The first command starts the server in background. You can also run it in anotherterminal.1$./server &$nc localhost 31000100100abcError NaN 100kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkError LongLine 100exitBye 100DeliverablesA Make file is provided. You should submit two C files, namely, server.c for the server, and client.cfor the client. Both files should be located in the lab7

View Full Document
Download Lab 7
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...

Join to view Lab 7 and access 3M+ class-specific study document.

We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Lab 7 2 2 and access 3M+ class-specific study document.


By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?