This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: Program Assignment 2 CMSC 417 Fall 2011 September 25 1 Deadline October 11, 2011 . 2 Objective In this assignment you will write the server program which will communicate using sockets with the client program we provide. Your server program will operate according to the protocol described in the next chapter. The project itself is somewhat trivial, however, this exercise will familiarize you with client/server programming and communication protocols. 3 Protocol The server runs on the machine SERVER HOSTNAME and listens for re- quests on a TCP socket bound to port SERVER PORT. Both constants are defined in the header file, “common.h”, provided for you. The protocol has four types of messages: HELLO, STATUS, CLIENT BYE and SERVER BYE. Each message is an ASCII string, and consists of mul- tiple fields separated by whitespace (space (0x20) or newline (0x0a) character) . The MAXIMUM length of the string is 255. The protocol outline is given in Fig 1. The client initiates the proto- col by sending a HELLO message to the server. The server replies with a STATUS message. The client then sends a CLIENT BYE message, and the server terminates the connection by sending a SERVER BYE message. A connection is successful if and only if all of these messages are correctly sent and received. Since we are using TCP for communication in this assignment, you do not have to worry about lost messages; you only need to ensure that all messages are sent correctly (and that you receive and parse messages 1 Figure 1: Protocol correctly). The details of each message are as follows: 1. HELLO (From the client to the server: Client → Server) The HELLO message has 4 fields EXACTLY in the following order: • Magic String It MUST set to be MAGIC STRING which is a constant defined...
View Full Document
This note was uploaded on 01/13/2012 for the course CMSC 417 taught by Professor Staff during the Fall '08 term at Maryland.
- Fall '08