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