public void Run()
{
lock (sync_)
{
if (State.SHUTDOWN_REQUESTED != state_)
tcpListener_.Start();
}
while (State.RUNNING == ReactorState)
{
try
{
TcpClient client = tcpListener_.AcceptTcpClient();
ApplySocketOptions(client, socketSettings_);
ClientHandlerThread t = new ClientHandlerThread(client, nextClientId_++, sessionDict_, socketSettings_);
t.Exited += OnClientHandlerThreadExited;
lock (sync_)
{
clientThreads_.Add(t.Id, t);
}
// FIXME set the client thread's exception handler here
t.Log("connected");
t.Start();
}
catch (System.Exception e)
{
if (State.RUNNING == ReactorState)
this.Log("Error accepting connection: " + e.Message);
}
}
ShutdownClientHandlerThreads();
}