FileDocCategorySizeDatePackage
TCPServer.javaAPI DocExample1749Tue Jan 28 17:28:16 GMT 1997None

TCPServer

public class TCPServer extends Object implements Runnable, Cloneable

Fields Summary
Thread
runner
ServerSocket
server
Socket
data
ThreadGroup
group
int
groupNo
Constructors Summary
Methods Summary
public synchronized voidStartServer(int port)


           
        if (runner == null) {
            server = new ServerSocket(port);
            runner = new Thread(this);
            runner.start();
        }
    
public synchronized voidStopServer()

        if (server != null) runner.stop();
    
public voidrun()

        if (server != null) {
            while (true) {
                try {
                    Socket datasocket = server.accept();
                    TCPServer newSocket = (TCPServer) clone();

                    newSocket.server = null;
                    newSocket.data = datasocket;
                    newSocket.group =
                        new ThreadGroup("Client Group " + groupNo++);
                    newSocket.runner =
                        new Thread(newSocket.group, newSocket);
                    newSocket.runner.start();
                } catch (Exception e) {}
            }
        } else {
            run(data);
        }
    
public voidrun(java.net.Socket data)