|
|
|
@ -79,18 +79,18 @@ public class ServerManagementTCP extends ServerManagement {
|
|
|
|
|
public void run() {
|
|
|
|
|
writeLog("Server sucessfully started", LogLevel.Info);
|
|
|
|
|
fileListWatcher = (FileWatcher)new FileWatcherTCP(logger, 10000, server, tracker, baseDirectory); // checking every 10 seconds
|
|
|
|
|
(new Thread(fileListWatcher)).start();
|
|
|
|
|
Thread flwt = new Thread(fileListWatcher);
|
|
|
|
|
flwt.start();
|
|
|
|
|
fileListWatcher.setThread(flwt);
|
|
|
|
|
while(!stop) {
|
|
|
|
|
try {
|
|
|
|
|
Socket s = socket.accept();
|
|
|
|
|
ClientHandler c = new ClientHandler(s);
|
|
|
|
|
(new Thread(c)).start();
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
writeLog("Error while accepting new connection", LogLevel.Warning);
|
|
|
|
|
writeLog("Socket has been closed", LogLevel.Info);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
fileListWatcher.setStop();
|
|
|
|
|
sendUnregisterRequest();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** Private runnable class allowing to serve one client.
|
|
|
|
@ -162,4 +162,13 @@ public class ServerManagementTCP extends ServerManagement {
|
|
|
|
|
protected Object getTrackerSocket() {
|
|
|
|
|
return (Object)tracker.getTCPSocket();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** Closes socket */
|
|
|
|
|
protected void closeSocket() {
|
|
|
|
|
try {
|
|
|
|
|
socket.close();
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
writeLog("Could not close socket", LogLevel.Error);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|