All pastes #615169 Raw Edit

Unnamed

public text v1 · immutable
·published 2007-07-11 23:38 UTC
rendered paste body

import java.io.*;
import java.util.*;
import java.net.*;
import static java.lang.System.out;

class Server {
	public static void main(String args[]) {
		
		Scanner myScanner = new Scanner(System.in);
		
		out.println("*********************************");
		out.println("*  ChatServ Server v1.0 \"Pyro\"  *");
		out.println("*********************************");
		out.println();
		out.println("Establishing server socket...");
		ServerSocket serverSocket = null;
		
		try {
    		serverSocket = new ServerSocket(72);
    		out.println("Server socket established, type Q to break connection and quit.");
    		out.println("> ");
    		String quitString = myScanner.next();
    		// ~~~~~~~~~~~~~~~~~~~ exitSpot ~~~~~~~~~~~~~~~~~~~~~~
    		if (quitString.toLowerCase() == "q") {
    			System.exit(0);
    		} else {
    			// ~~~~~~~~~~~~~~~~ GOTO "exitSpot" ~~~~~~~~~~~~~~~~~
    		}
		} catch (IOException e) {
			die("Could not listen on port 72!");
		}
	
	Socket clientSocket = null;
	try {
    	clientSocket = serverSocket.accept();
	} catch (IOException e) {
		die("Could not accept connection!");
	}
	
	}
	
	public static void die(String text) {
		out.println(text);
		System.exit(0);
	}
}