FileDocCategorySizeDatePackage
TCPServer.javaAPI DocExample1712Tue Jan 28 17:20:08 GMT 1997None

TCPServer

public class TCPServer extends Object implements Runnable, Cloneable

Fields Summary
Thread
runner
ServerSocket
server
Socket
data
Constructors Summary
Methods Summary
public voidrun()

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

                    newSocket.server = null;
                    newSocket.data = datasocket;
                    newSocket.runner = new Thread(newSocket);
                    newSocket.runner.start();
                } catch (Exception e) {}
            }
        } else {
            run(data);
        }
    
public voidrun(java.net.Socket data)

 
    
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();
            runner == null;
            server.close();
        }