Simple Chat Client and Server
=============================

Summary
-------

This is a very small demonstration of a Winsock control
based multiuser chat system in VB.  It handles stream
fragmentation by buffering incoming data and splitting
out completed messages based on a trailing delimiter
character as the "end of message" marker.

The statistics accumulation and display could be ripped
out, but otherwise it is a fairly minimal chat system.

NOTE:

This version uses application-level KeepAlives.


Why This Demo?
--------------

The point of this demonstration is to illustrate how to
use TCP streams via Winsock controls for client/server
messaging.  It shows one way to buffer incoming stream
fragments, parse them into messages, and then process
them.

This technique avoids the breaking of messages and the
apparent "clumping effect" that bedevils so many new
Winsock programmers.  Some of these effects don't
manifest themselves in early testing on a LAN, making
them doubly frustrating when testing over the Internet
or dial connections begins.

All of this is done without any tricks, and no randomly
inserted calls to VB's DoEvents() function.


The server is dead simple
-------------------------

It simply accepts incoming connections from new clients
and any messages received are prefixed with a timestamp
and then forwarded back out to all connected clients.
Some simple statistics about connections and the
messages received are displayed, and status information
is logged to a scrolling textbox.


The client is almost as trivial
-------------------------------

It connects to the server, and text typed into a textbox
gets prefixed with the "user name" and sent to the
server.  Any status info and messages received back from
the server are displayed in a scrolling textbox.


Use
---

Only VB 6.0 source is provided, so both the client and
the server projects should be compiled first.

Then run the server, set its port number, and click on
its Listen button.

Run one or more client instances and fill in the port,
server, and user name textboxes.  Then click on the
Connect button and begin typing.  Pressing the Enter
key sends your typed messages to all connected clients,
including echoing your message back to your client.

When testing on one PC use "localhost" (without the
quotes) as the server name.


Caveats
-------

This demo isn't meant to be a speed demon, and adding
file transfer functionality to it won't result in high
throughput performance.  It also may need a bit more
debugging to uncover lingering "warts."  So far it
seems pretty solid though.