/// <summary>
/// TODO apply networking options, e.g. NO DELAY, LINGER, etc.
/// </summary>
public void Run()
{
tcpListener_.Start();
while (State.RUNNING == ReactorState)
{
try
{
TcpClient client = tcpListener_.AcceptTcpClient();
ApplySocketOptions(client);
ClientHandlerThread t = new ClientHandlerThread(client, nextClientId_++);
lock (sync_)
{
clientThreads_.AddLast(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();
}