private ServerSocket serverSocket = null;
private boolean listening = true;
try {
serverSocket = new ServerSocket(port);
} catch (IOException e) {
System.out.println("Could not listen on port: " + port);
e.printStackTrace();
System.exit(-1);
}
System.out.println("Server listening on " + serverSocket.getInetAddress() + ":" + port);
try {
while (listening) new ClientServerThread(serverSocket.accept(), this).start();
serverSocket.close();
} catch (IOException e) {
System.out.println("Could not listen on port: " + port);
e.printStackTrace();
System.exit(-1);
}
|