Server Class

Server’s constructor (Fig. 28.3, lines 30–55) creates the server’s GUI, which contains a JTextField and a JTextArea. Server displays its output in the JTextArea. When the main method (lines 6–11 of Fig. 28.4) executes, it creates a Server object, specifies the window’s default close operation and calls method runServer (Fig. 28.3, lines 57–86).

 1   // Fig. 28.3: Server.java  2   // Server portion of a client/server stream-socket connection.  3   import java.io.EOFException;  4   import java.io.IOException;  5   import java.io.ObjectInputStream;  6   import java.io.ObjectOutputStream;  7   import java.net.ServerSocket;  8   import java.net.Socket;        9   import java.awt.BorderLayout; 10   import ...

Get Java™ How To Program (Early Objects), Tenth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.