private void OnSocketAccept(object acceptedSocket)
{
if (!_shutdownInProgress)
{
Connection conn = new Connection(this, (Socket)acceptedSocket);
// wait for at least some input
if (conn.WaitForRequestBytes() == 0)
{
conn.WriteErrorAndClose(400);
return;
}
// find or create host
Host host = GetHost();
if (host == null)
{
conn.WriteErrorAndClose(500);
return;
}
// process request in worker app domain
host.ProcessRequest(conn);
}
}