Java Reference
In-Depth Information
Compile this source code ( javac ChatServer.java ) and run the application
( java ChatServer ).Itrespondsbypresentingthefollowingoutputinitscommand
window:
ChatServer starting
listening on port 8010
Listing 9-3 presents ChatClient 's source code.
Listing 9-3. Accessing the chat server
import java.awt.BorderLayout;
import java.awt.EventQueue;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.net.Socket;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.border.Border;
import javax.swing.border.EtchedBorder;
class ChatClient
{
Search WWH ::




Custom Search