-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHttpServerMainThread.java
More file actions
29 lines (25 loc) · 950 Bytes
/
Copy pathHttpServerMainThread.java
File metadata and controls
29 lines (25 loc) · 950 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import Server.HttpListener;
import Server.Utils.Logger;
import java.net.ServerSocket;
public class HttpServerMainThread extends Thread{
private final int port;
public final boolean lb;
public HttpServerMainThread(int port,boolean lb){
this.lb = lb;
this.port = port;
this.start();
}
@Override
public void run(){
try{
ServerSocket server = new ServerSocket(port);
Logger.ilog("Http server thread is now running on port " + port + " ..." + (lb ? "(Load balancer)" : ""));
System.out.println("Http server thread is now running on port " + port + " ..." + (lb ? "(Load balancer)" : ""));
while(true) new HttpListener(server.accept(),"default",lb);
}catch (Exception ex) {
Logger.logException(ex);
}
Logger.ilog("Server is shutting down ...");
System.out.println("Server is shutting down ...");
}
}