Change the file name

This commit is contained in:
DevSnaith 2023-04-19 10:47:24 +03:00
parent 3ffa7805ca
commit 565bb791ca

View File

@ -32,14 +32,14 @@ public class RequestListener implements Runnable {
try {
server = new ServerSocket(port);
thread = new Thread(this, threadName);
isRunning = true;
thread.start();
} catch (Exception ex) {
l.printf(LogLevel.ERROR, ex instanceof IllegalArgumentException ?
"Server port must be between 0 and 65535" : ex.getMessage(), null);
}
thread = new Thread(this, threadName);
isRunning = true;
thread.start();
}
public synchronized void stop() {
@ -65,24 +65,25 @@ public class RequestListener implements Runnable {
public void run() {
l.printf(LogLevel.INFO, threadName + " using port " + getPort(), null);
while(isRunning && !thread.isInterrupted()) {
try {
if(server == null) {
stop();
continue;
}
Socket s = server.accept();
if(e != null)
e.onConnection(s);
// l.printf(LogLevel.INFO, "New Connection " + s.getInetAddress().getHostAddress(), null);
} catch (IOException ex) {
l.printf(LogLevel.ERROR, ex.getMessage(), null);
if(server != null) {
try {
Socket s = server.accept();
if(e != null)
e.onConnection(s);
} catch (IOException ex) {
l.printf(LogLevel.ERROR, ex.getMessage(), null);
}
continue;
}
stop();
}
l.printf(LogLevel.INFO, threadName + " has been stopped", null);
}
public boolean isRunning() {
return isRunning;
}
public int getPort() {
return this.port;
}