Добавил:
Eatmore
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:отчеты по лабораторным работам / лабораторная работа 3 / MainFrame / src / mainframe / Server
.java 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();
}
}
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