Cryptography Reference
In-Depth Information
make the input buffer at least as long as the number of bytes you expect to receive, or not
all the bytes will be read in. This should be adequate for you to understand the byte IO in
the chat program that follows.
I'll start with a screen shot of the CipherChat Server, because looking at the GUI helps
to explain the components we will see later in the code. (See Figure 15.1.) It has a button
to disconnect from the client (it starts out disabled), a field to type messages in, and an out-
put area which displays incoming messages, plus information on the connection.
Here is the code for CipherChatServer. I will
explain the code as I present it.
import java.io.*;
import java.net.*;
import java.awt.*;
import java.awt.event.*;
import java.math.*;
import java.security.*;
public class CipherChatServer extends Frame implements ActionListener {
The following are all the objects the server will need. They are:
1.
The graphical components for the chat window.
2.
The objects used for input and output.
3.
The networking objects required to establish a connection.
FIGURE 15.1
Search WWH ::




Custom Search