FileDocCategorySizeDatePackage
TCPServer.javaAPI DocExample2493Thu Feb 04 16:10:46 GMT 1999None

TCPServer

public class TCPServer extends Object implements Runnable, Cloneable

Fields Summary
Thread
runner
ServerSocket
server
Socket
data
boolean
shouldStop
ThreadGroup
group
int
groupNo
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.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)

 
	
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;
		}