You are on page 1of 2

COM324 – System Programming

Fall 2007-2008
Computer Engineering Department
Near East University
Homework 6
Week of December 31, 2007
due in class, on Friday, January 11, 2007

Consider the source code for client and server given in Chapter 10 of your textbook. Complete the
implementation of both the client and server source code according to the following specifications:

1. The client should be run as follows:

./client <name> <message> <ip> <port>

where <name> is an arbitrary name for identifying each client, <message> is a text message to be sent to
the server, <ip> is the server IP, and <port> is the port to which to connect on the server.
After connecting to the server, the client should send the <name> and the <message> to the server. Then
the client should wait for a message from the server. It should receive that message, print it out, and
finally exit after a brief wait, in order to allow the server to receive the two pieces of information sent.

2. The server should be run as follows:

./server <port>

where <port> is the port on which the server should run. This is the same port to which clients will later
connect.
For each client, the server, in a child process, must first receive the name of that client and the message
sent by that client. In reply, the server must read the current date and time, send this information back
to the client and close its connection with that client.
The date and time should be printed in the following format:

<Day>, <Month> <Day>, <Year> -- <Hour>:<Minutes> [AM|PM]

An example C program will be provided (See course website) that demonstrates how local time and date
may be printed out in the above format. An example output of the example program is:

Time & Date: Saturday, January 05, 2008 -- 02:15 PM

3. Below is an example interaction between a client and the server. Suppose the following two commands
are used to start the server and run the client:

./server 7000

./client Jane "I’m leaving for dinner" 127.0.0.1 7000


The client will send its name Jane and the message "I’m leaving for dinner" to the server.
The server should receive the name and the message separately, and then it should print out both
the name of client who sent the message and the content of the message in a format such as
Jane: "I’m leaving for dinner." to the screen.
Then, the child process handling the client connection should read the current date and time, parepare
a string containing the required information mentioned earlier, and send this string back to the client as
reply.
The client then should receive this date and time string and print it out. For example:

Saturday, January 05, 2008 -- 02:25 PM

Submission Requirements
• Your typed program.

• No software submissions on a CD/DVD is required. No emails please.

• Use the script command to record your run sessions. Provide this output as validation of the correctness
of your programs. Please edit the typescript file produced by script to remove uncessary content.

• Please use the provided standard cover page when submitting your work.

• No late submissions please!

You might also like