async Task AcceptAsync(CancellationToken t)
        {
            logger.Site().Information("Accepting connections on {0}", ListenEndpoint);
            while (!t.IsCancellationRequested)
            {
                HybridConnectionStream connectionStream = null;

                try
                {
                    connectionStream = await listener.AcceptConnectionAsync();

                    logger.Site().Debug("Accepted connection from {0}.", listener.Address);

                    var connection = RelayEpoxyConnection.MakeServerConnection(
                        parentTransport,
                        this,
                        serviceHost,
                        connectionStream,
                        logger,
                        metrics);

                    lock (connectionsLock)
                    {
                        connections.Add(connection);
                    }

                    await connection.StartAsync();

                    logger.Site().Debug("Started server-side connection for {0}", connection);
                }
                catch (AuthenticationException ex)
                {
                    logger.Site().Error(ex, "Failed to authenticate remote connection from {0}", connectionStream);
                    ShutdownSocketSafe(connectionStream);
                }
                catch (SocketException ex)
                {
                    logger.Site().Error(ex, "Accept failed with error {0}.", ex.SocketErrorCode);
                    ShutdownSocketSafe(connectionStream);
                }
                catch (ObjectDisposedException)
                {
                    ShutdownSocketSafe(connectionStream);
                }
            }

            logger.Site().Information("Shutting down connection on {0}", ListenEndpoint);
        }
Ejemplo n.º 2
0
 public RelayEpoxySendContext(RelayEpoxyConnection connection, ConnectionMetrics connectionMetrics, RequestMetrics requestMetrics)
     : base(connectionMetrics, requestMetrics)
 {
     Connection = connection;
 }