CS
457 Project 1: Simple Chat Program
|
|||||||||
| Server | Client |
|---|---|
| $./chat Welcome to Chat! Waiting for a connection on 192.82.47.232 port 3360 Found a friend! You receive first. Friend: hello! You: Hi! How are you? Friend: I'm great. You: That's good. Ok, bye! ^C |
$./chat -p 3360 -s 192.82.47.232 Connecting to server... Connected! Connected to a friend! You send first. You: hello! Friend: Hi! How are you? You: I'm great. Friend: That's good. Ok, bye! You: ▐ |
| $./chat -p 3360 -s 192.82.47.232 Connecting to server... Connected! Connected to a friend! You send first. You: hello! I just got back from lake Chargoggagoggmanchauggagoggchaubunagungamaugg. Next year, we are going on a trip to the Mississippi river to go fishing! Error: Input too long. You: Hello! Friend: Hi! You: ▐ |
The program is invoked as follows:
Server
side:
$./chat
Client side:
$./chat -p 3790 -s 192.168.47.232
Where the -p flag indicates the port to connect to and the -s flag indicates the IP address of your friend.
$./chat -h
Should produce a help message and exit.
Without any arguments, the chat program acts as a server,
prints out the port it is listening on and waits for a
connection.
With arguments, the program acts as a client connects to a
waiting server using the information provided.
With one argument, the program prints the help message and
exits.
The arguments may be in any order and should be
sanity-checked. For example, a port must be a number (no
letters) and a server address must also be numbers but
with the "." character allowed.
You must include a readme that explains to a
potential user the process of invoking your program. You
may assume that the user is familiar with using terminal
programs. Also include questions that you asked the TA and
the answer to those questions and any assumptions you have
made along the way (hint: ask before assuming!).
You must include a makefile that produces an executable
called chat.
Programs will be randomly paired up and will have their
client and server tested with the other's client and
server. To make this possible, you must follow the packet
format specified below.
| Version (16 bits, Binary) | string length (16 bits, Binary) |
| Message (up to 140 bytes, ASCII) | |
Where the Version is always 457, the string length is the
length of the message in bytes, and the message follows
immediately afterwards. To test this, your TA has written
a test client and a test server so that you can check your
interactions. Reference binaries
are here: chat_32, and chat_64. Note that chat_32 should
work on both 32 and 64-bit machines, whereas chat_64
only works on 64-bit machines.
Don't forget to change file permissions after download
to make it executable. In Linux simply type: