Chat Room Comes Back With A New Face

Environment: VC6 /Win 2K/Win XP



  • I
    believe the diagram would speak for itself. Still, I have to point out
    that the actual code would not strictly follow the building blocks shown
    above, as the design- programming is always an interactive activity which
    requires the continuous modification.


The design of the server is a litter different from the client.

Two CSocket derived classes are used. One is listening to the
ports, once a request for connection is coming, a new clientsocket is created
and its info is added to a linklist maintained by the main dialog (in my case,

I removed the burden of Sending/Receiving message from main
dialog (CChatServer) to the client socket class. The main dialog is
responsible for the forwarding and coordination of the messages between
clients, in other words, a manipulation of the linklist


to test this program

        Since only source
file is provided, you need Visual C++ for compilation.

    Open the chat – server project, run it, click the “start” button, the
    IP of the current machine appears on the right;

    Open the chat client project, press “connection” button, change
    the IP address to the one shown on the server side, then ok. Next, press
    “Sign in” button, and begin to chat.
    Functionality of the buttons below are (from left to right):
    “Connection”, “Sign in”, “Sign out”, “my icon”(N/A), “On
    leave”(N/A), “About”.


            I used Visual
C++ 6.0 / Window Xp/2K to do the test.



  • Rich
    text editing;

  • Persistence;
    your customized setting will be remembered and recalled next time.



I did find some bugs when I operated server a lot (stop, start, stop, start) while the clients were still linking. For example, if the client logs off during the period while the server stops services, the other clients of cause couldn’t get his log off info. Since in the normal circumstance the server is supposed not to be bothered after it’s started, I did no bother to fix that part.

I tested on a single machine( Win XP installed) and also test in the
LAN of my lab(Win2K installed ). I was carefully to avert the possible error. So I
believe you guys will find many more bugs, just don’t hesitated to let me
know. Of course, if you can solve them on your own, that’d be better. J

for update


There is a lot of room for update.

  1. The
    icon button is a fake, no response to the users’ input. It needs to be
  2. The
    contact list box on the right is a fake, no icons – just names, and can’t
    do anything. It needs
    to be improved for personal talk;

  3. The
    persistence is machine dependent instead of account dependent,
    which means different users get the same setting if he run this program on
    the same machine. It’s not a mistake, but the account dependent
    setting is more “professional”. Suggestion: use GetProfileIni/WriteProfileIni
    to do the persistence.

  4. Private
    conversations. People need to single out a certain guy for a private talk.
    Like MSN message; Matthem Millman did that with multi thread. But
    automation tech might be an alternative;

  5. File

  6. Pop3
    mail reminder.

 I’ll do these updates in the coming days, maybe after


I finished this project( maybe not yet J)
within two weeks by myself, in my spare time at night. However, without the
genius idea and code on codeguru, I couldn’t make it. So many thanks should
go to the people contributing their effort to this great website. Also, direct
helps from the following guys are highly appreciated:

  • Matthem
       for his
    NetMsg and the clear presentation of 
    the usage of CSocket;

  • Kirk
    W. Stowell
     for his cool
    CFlatcombobox  control;

  • Daniel
    G. Hyams
    for his great expansion dialog code, which goes into my code

  • Bogdan
    for his powerful property sheet wizard, which helped me to
    construct my server in a professional way.

Also many thanks go to the
people emailed me, commented on my previous article, and answered my questions
on the discussion board. I sincerely request you for the continuing supports
for this one too.


As I mentioned at first, I
am now looking for a proper job as a programmer
. I like to use C/C++ and
Java as my programming languages, my preferred IDE is Visual C++ studio and
Forte from SUN. My computer skills are including but not limit to the
programming ability. Web authoring and script writing are also my interests. I
use Linux and IRIX from SGI doing my work as well. I also sometime consult on
campus. I like to talk with people on all topics. At last, my loyalty and
diligence is of no doubt because, this kind of work, is something I really
fond of.

Work area includes any state within the


Any offer or suggestion is quite welcomed. Please contact me through

[email protected], or [email protected].

I’ll send you my resume and ready to answer your

Thank you all, and enjoy coding!


Chat server source code (116 kb)

Chat client source code (342 kb)


More by Author

Must Read