FileDocCategorySizeDatePackage
SocketServer.javaAPI DocExample1014Sun Feb 06 09:23:30 GMT 2000None

SocketServer

public class SocketServer extends Thread

Fields Summary
static final int
MINUTES
The hang-around time
public static final int
PORT
The port number
ServerSocket
ss
The server socket.
Constructors Summary
public SocketServer()
Constructor -- just creates the ServerSocket


	       
	    
		ss = new ServerSocket(PORT);
	
Methods Summary
public static voidmain(java.lang.String[] argv)

		new SocketServer().start();
	
public voidrun()

		while (true) {
			try {
			System.out.println("SocketServer waiting for connection");
			Socket s = ss.accept();
			BufferedReader is = new BufferedReader(
				new InputStreamReader(s.getInputStream()));
			String name = is.readLine();
			String passwd = is.readLine();
			String domain = is.readLine();
			PrintWriter pout = new PrintWriter(s.getOutputStream(), true);
			pout.println("Welcome to " + domain + ", " + name);
			} catch (IOException e) {
				System.err.println("Oh, dear me! " + e);
			}
		}