TWiki> CS450fall09 Web>Homework3 (2009-09-14, Main.jakob)EditAttach

Homework 3 - due Mon 9/21

In this homework, we finally get to the mother of all serious socket programming: the select() system call.

select() allows a program to wait for multiple file descriptors at once, whether reading, writing or just looking for error messages from a socket.

Create a simple chat server for telnet clients, using TCP sockets and select(). Let every connected client receive using TCP sockets and every message sent by every other client.

Pay attention to the details. Specifically, you are required to handle the commands "say" and "name", keep track of and report (on connection close) the number of received bytes for each client. You should also keep track of and use the name set by the client, as shown below. The number of clients can be more than two, but will be less than 16 during grading.

Here is an example transcript with 2 connected telnet clients:

./hw3 10080
Got connection (Client 1).
Client 1 set name to: Jakob
Got connection (Client 2).
Jakob said: Hello
Jakob said: How are you?
Client 2 said: Hello, I am fine.
Client 1 said: Who are you?
Client 2 set name to: Tomas.
Tomas disconnected. A total of 27 bytes received from Tomas.
Jakob disconnected. A total of 28 bytes received from Jakob.

where one of the telnet sessions would look like:

telnet localhost 10080
name Jakob
Client 2 connected.
say Hello
say How are you?
Client 2> Hello, I am fine.
say Who are you?
Client 2 set name to: Tomas.
Tomas disconnected.
^]
close

TIP: the selectserver.c example will give you an excellent start.

Topic revision: r1 - 2009-09-14 - 02:29:18 - Main.jakob
 
Copyright 2016 The Board of Trustees
of the University of Illinois.webmaster@cs.uic.edu
WISEST
Helping Women Faculty Advance
Funded by NSF