Exemple #1
0
 private void AcceptCallback(IAsyncResult ar) {
     Trace("Server - Connection Recieved");
     Socket socket;
     try {
         socket = _listener.EndAcceptSocket(ar);
     }
     catch (ObjectDisposedException) {
         return;
     }
     _listener.BeginAcceptSocket(AcceptCallback, null);
     var session = new TcpSession(_host.Environment, _appFunc, socket);
     session.ProcessRequest()
            .ContinueWith(task => {
                              if (task.IsFaulted) {
                                  Trace(task.Exception != null ? task.Exception.Message : "A bad thing happened.");
                              }
                              Trace("Server - Session Closed");
                              session.Dispose();
                          });
 }