Ramsey's CSI 470 - Computer Networks

In this homework you'll be writing a chat client to interact with a chat server. To grab the sample python client type the following (Please note that the trailing periods are necessary):
cp ~sramsey2/tmp/cl.py .


All messages are sent in this format:
xxwwwwwwwwwwww

xx is a two-digit number represented by the ascii characters that describes how many bytes of wwww there shall be.

Thus, a client may send:

05MSG a

To represent sending 5 bytes which are "MSG a"

All messages are sent and received with this protocol.
So a login might be:
10LOGIN fo be

And a Whisper might be:
24W doc How are you today?




In this assignment you'll need to use the select function call. select
is useful in that it will fill queues that are ready to be processed
when they arrive. A good example is available here:
Echo Server

Your program will need to select only on input and the connected
server socket. When we write the chat servers, they will need to
select on the listen, the clients and user input.

The server will be running on sybil on port 34998.

The application level protocol consists of three things.

1) LOGIN username password In this case the client sends this string
  to log into the server. The client must send a LOGIN before it sends
  any other messages. username and password must both be
  alphanumeric. Python has a command called isalnum that will be
  useful for this. The server will respond with a response that begins
  with "NO" any time a LOGIN has failed. In general, the server sends
  "NO" followed by an explanation to misunderstood messages. For
  example, the server might send: "NO - username/password pair does
  not exist" A successful login will receive a welcome message from
  the server.

2) MSG WHO or WHO - In either of these two cases, the server will
  respond with a list of the currently connected user names

3) MSG message - In this case the client can send any message to the
  server to be sent to all other clients. The server will also send
  this message back to the client.


4) W username message - In this case the client is trying to send a
  message only to a specific user.  (This is optional for your
  clients, but it is implemented by the server.) Server will send a
  "NO ..." message if it cannot whisper and a successful whisper message
  otherwise.


After login, in general, the client should wait for user input or
messages from the server (using the select). If the user types
something, it should send that to the server and then go back to
waiting. If the server has sent a message, the client should get the
message and display it and go back to waiting. 


The server will send messages from other users. On user input, the
client will be sending a MSG command or a W command as per your own
client user interface.