class SSServer { public static void main (String [] args) throws IOException { System.out.PRintln ("Server starting.../n");
// Create a server socket that listens for incoming connection // requests on port 10000.
ServerSocket server = new ServerSocket (10000);
while (true) { // Listen for incoming connection requests from client // programs, establish a connection, and return a Socket // object that represents this connection.
Socket s = server.accept ();
System.out.println ("Accepting Connection.../n");
// Start a thread to handle the connection.
new ServerThread (s).start (); } } }
class ServerThread extends Thread { private Socket s;
ServerThread (Socket s) { this.s = s; }
public void run () { BufferedReader br = null; PrintWriter pw = null;
try { // Create an input stream reader that chains to the socket's // byte-oriented input stream. The input stream reader // converts bytes read from the socket to characters. The // conversion is based on the platform's default character // set.
InputStreamReader isr; isr = new InputStreamReader (s.getInputStream ());
// Create a buffered reader that chains to the input stream // reader. The buffered reader supplies a convenient method // for reading entire lines of text.
br = new BufferedReader (isr);
// Create a print writer that chains to the socket's byte- // oriented output stream. The print writer creates an