FileDocCategorySizeDatePackage
TCPServer.javaAPI DocExample2362Thu Feb 04 16:10:36 GMT 1999None

TCPServer

public class TCPServer extends Object implements Runnable, Cloneable

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

		if (server != null) {
			while (!shouldStop) {
				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) {
			shouldStop = true;
			runner.interrupt();
			runner = null;
			try {
				server.close();
			} catch (IOException ioe) {}
			server = null;
		}