Скачиваний:
64
Добавлен:
09.05.2014
Размер:
1.11 Кб
Скачать
package mainframe;

import java.io.*;

public class Server {

private static final int DEFAULT_PORT = 7070;

public static void main(String args[]) {
int port = DEFAULT_PORT;
boolean exitFlag = false;
BufferedReader input = new BufferedReader(new InputStreamReader(System.in));

if (args.length > 0) {
try {
port = Integer.parseInt(args[0]);
} catch (NumberFormatException e) {
System.out.println("Illegal port! The port was set by default!");
}
}

ServerReceiver sr = new ServerReceiver(port);

do {
System.out.println("Enter the \"exit\" command close the application:");
try {
if (input.readLine().equalsIgnoreCase("exit")) {
exitFlag = true;
}
} catch (IOException e) {
System.out.println("Application will be closed!");
sr.stop();
return;
}
} while (!exitFlag);
sr.stop();
}
}
Соседние файлы в папке mainframe