Outubro 2008
Prof. Ismael H. F. Santos -  ismael@tecgraf.puc-rio.br                                                          2
TCP server makes a connection for each client and then echoes the client’s  request
import java.net.*;
import java.io.*;
public class TCPServer {
    public static void main (String args[]) {
       try{
          int serverPort = 7896;
          ServerSocket listenSocket = new ServerSocket(serverPort);
           while(true) {
Socket clientSocket = listenSocket.accept();
Connection c = new Connection(clientSocket);
            }
       } catch(IOException e) {
          System.out.println("Listen :"+e.getMessage());
       }
    }
}
// this figure continues on the next slide