1
0
Fork 0
mirror of https://github.com/ethauvin/kobalt.git synced 2025-04-26 08:27:12 -07:00

More robust server loop.

This commit is contained in:
Cedric Beust 2015-10-28 21:23:51 -07:00
parent 5958bf0c5d
commit e252a5386c

View file

@ -69,8 +69,8 @@ public class KobaltServer @Inject constructor(val args: Args) : Runnable, IComma
log(1, "Listening to port $portNumber")
var quit = false
val serverSocket = ServerSocket(portNumber)
while (! quit) {
val clientSocket = serverSocket.accept()
val clientSocket = serverSocket.accept()
while (!quit) {
outgoing = PrintWriter(clientSocket.outputStream, true)
if (pending.size > 0) {
log(1, "Emptying the queue, size $pending.size()")
@ -99,6 +99,8 @@ public class KobaltServer @Inject constructor(val args: Args) : Runnable, IComma
}
} catch(ex: SocketException) {
log(1, "Client disconnected, resetting")
} catch(ex: Exception) {
log(1, "Command failed: ${ex.message}")
}
}
}