CS-360, Assignment 8
Due Date: 12-3-07

In this assignment you are to implement a mini chatroom that 
enables two users on different computers to communicate over the 
internet using .NET network streams. You will need to write two 
programs similar to the ChatServer and ChatClient appliations 
discussed in class. Both of these should be .NET programs
written in C# using some of the classes built into the 
System.NET.Sockets namespace. The windows that these applications
display should be similar to those shown below. In these diagrams 
a network connection has already been established. Please note 
that the controls used in these applications are NOT the same as 
the ones in the example programs discussed in class.





The Server application should have a textbox in which the user can 
enter the port number it will listen on for attempts to connect 
from client programs. It starts listening when the user clicks the 
"Listen" button. Subsequently, when a client application attempts 
to connect, the server application should set up a socket connection 
that will be used to send/receive messages from the client over 
the network using a network stream, a binary writer, and a binary 
reader as described in class.

The Client application should have two textboxes in which the
user can enter the IP address (or DNS name) of the machine on which
the server is running and the port to be used. When its "Connect"
button is pressed, the application should try to connect to the
Server application running on the other machine.

Once a connection is established between the two applications (which
would normally be running on different computers, but in the examples 
shown in the diagrams above are running on the same machine using the 
"loopback" address), either user should be able to type message 
strings into a "Message" textbox. Then when the sender application's 
"Send" button is clicked, the string should be sent over the network 
stream. As that happens, the string should be added to a "Sent" 
listbox in the sender's window, and when it is received by the other
application, it should be added to a "Received" listbox in the 
receiver's window.

In the diagrams above, the Client has typed in the message, "Hello, 
Server. How are you?". Note that that message appeared in its "Sent" 
list box as soon as the user clicked the "Send" button. Note also that 
the message subsequently appeared in the Server's "Received" list box 
after he received it. In the diagrams above we notice that after that 
message appeared, the Server typed the reply, "Hi, yourself, Client. 
I'm fine" which was sent immediately after the user of the Server 
application clicked his "Send" button. This caused the reply to appear 
in his "Sent" list box and, when received by the Client, to also 
appear in the latter's "Received" listbox.

Each application should have a "Close" button which, when pressed,
will cause the connection to be closed. They should also have an "OK" 
button, which when clicked, will terminate the application.

You should program both applications in such a way that the various 
controls in the applications' windows are enabled only when it makes 
sense for them to be enabled.

Details of how to set up and build a basic chat server and chat client 
application are given in the class notes. Once again, please note that 
although these are similar to what you are supposed to implement, they 
are NOT the same.
You should include the directories for both applications on the CD-ROM 
that you submit. Also submit printed listings of the C# source code for 
each program.