forked from budsonjelmont/automatePipeline-autoLoad
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathASServerSocket.java
38 lines (30 loc) · 1013 Bytes
/
ASServerSocket.java
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
30
31
32
33
34
35
36
37
38
package autoLoad;
import java.io.IOException;
import java.net.ServerSocket;
import javax.swing.JOptionPane;
import modules.Params;
public class ASServerSocket extends Thread {
private MainForm _mainForm;
private Params _params;
public ASServerSocket(MainForm mainForm, Params params) {
super("ASServerSocket");
_mainForm = mainForm;
_params = params;
}
public void run() {
boolean listening = true;
try {
ServerSocket serverSocket = new ServerSocket(Integer.parseInt(_params.getGlobalParam("LOADER.Port", "1003")));
_mainForm.log("AutoUpdate is listening on port " + serverSocket.getLocalPort());
while(listening) {
new ASClientThread(serverSocket.accept(), _mainForm).start();
}
serverSocket.close();
} catch (IOException e) {
System.err.println("Could not listen on designatd port");
JOptionPane.showMessageDialog(_mainForm, "Cannot open a socket on the designated port", null, JOptionPane.ERROR_MESSAGE);
e.printStackTrace();
System.exit(-1);
}
}
}