private void OnConnect()

in src/log4net/Appender/TelnetAppender.cs [323:368]


    private void OnConnect(IAsyncResult asyncResult)
    {
      if (_wasDisposed)
      {
        return;
      }

      try
      {
        // Block until a client connects
        Socket socket = _serverSocket.EndAccept(asyncResult);
        LogLog.Debug(_declaringType, $"Accepting connection from [{socket.RemoteEndPoint}]");
        SocketClient client = new(socket);

        // clients.Count is an atomic read that can be done outside the lock.
        int currentActiveConnectionsCount = _clients.Count;
        if (currentActiveConnectionsCount < MaxConnections)
        {
          try
          {
            client.Send($"TelnetAppender v1.0 ({currentActiveConnectionsCount + 1} active connections)\r\n\r\n");
            AddClient(client);
          }
          catch (Exception e) when (!e.IsFatal())
          {
            client.Dispose();
          }
        }
        else
        {
          client.Send("Sorry - Too many connections.\r\n");
          client.Dispose();
        }
      }
      catch (Exception e) when (!e.IsFatal())
      {
        // Ignore
      }
      finally
      {
        if (!_wasDisposed)
        {
          AcceptConnection();
        }
      }
    }