Building an Internet chat system - seeing it in action

This is a companion page to the main JavaWorld article.

The chat system in action

Here, we demonstrate the chat system with an Applet variant of the ChatClient class. The code is essentially the same as the original ChatClient class, except that the host name and port come from parameters, and the class must fit within the Applet execution model with init(), start() and stop() methods.

You need a Java-enabled browser such as Microsoft® Internet Explorer or Netscape Navigator to see the chat system in action.
Chat Applet

Note that this Applet will not operate correctly through a firewall or proxy; the client will not be permitted to open a direct Socket connection back to the server. It also may not work with Netscape for Macintosh; the Mac-based Java VM still appears to be teething. Finally, you'll notice that once the window fills up with type, additinal lines don't become visible unless you manually scroll downward (using the scroll bar, of course). This inconvience is due to an AWT bug.

If the client encounters a problem connecting to the server, an exception will be thrown. If you can't connect, the server may be having difficulties; it is running on a lamentable Linux box. Try reloading the page to see if you can connect later.

· The source

The source for these classes is provided as either separate Java source files, or a single zip file that includes both source and the compiled class files. Hint: on Unix or Windows, click the right mouse button on a link to download the source files; on a Mac, hold the mouse button down.

To return to the article, just follow this link.


Copyright © 1996 by Manning Publications Co. All rights reserved.