The Chat Client

Your mission is to write a chat client. It should work with the server that can I give you.
You can find a sample client to modify at http://euclid.nmu.edu/~rappleto/Classes/CS228/Programming/SendFile/client.cc.
You can find a working server at http://euclid.nmu.edu/~rappleto/Classes/CS228/Assignments/ChatClient/server.cc. I already have it running at euclid.nmu.edu on port 1234

The server takes three kinds of messages.

  1. A message that has exactly four bytes which are 'Q', 'U', 'I', and 'T'.  This must be in all caps.  This cannot have a null character.  It must be just those four bytes.  This causes the server to close the connection.

  2. A message that starts with the four bytes 'N', 'A', 'M', or 'E'.  This must be in all caps.  This causes the server to change your name to whatever follows the 'E'.  Therefore the message "NAMEfred" will cause the server to change your name to "fred". Note there is no space.

  3. Any other message. This is just taken as a text for the server, which will reply.

A perfect client will do the following things in this order.

  1. Open a socket to the server.

  2. Send a "NAME" command to give the server your name.

  3. Get an answer back from the server. Print it to the screen.

  4. Loop

    1. Get Text from the keyboard

    2. Send it to the server.

    3. Read an answer back from the server. Print it to the screen.

  5. Until they type "quit" in any case

  6. Send the "QUIT" command in all caps

  7. Close the connection

  8. Exit

You get six points for having basic messaging working. You get two points for having the 'name' command working, and another two for the 'quit' command. You lose one point each day if it's turned in past