private void AcceptConnections()
        {
            while (_serverStarted)
            {
                // Accept a connection
                var connection = new ConnectionInfo();

                var socket = _serverSocket.Accept();
                socket.ReceiveTimeout = ReceiveTimeout;
                socket.SendTimeout    = SendTimeout;

                connection.LocalSocket  = socket;
                connection.RemoteSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)
                {
                    SendTimeout    = SendTimeout,
                    ReceiveTimeout = ReceiveTimeout,
                };

                // Create the thread for the receive
                var thread = new Thread(ProcessLocalConnection)
                {
                    IsBackground = true
                };
                thread.Start(connection);

                var remoteIpEndPoint = (IPEndPoint)connection.LocalSocket.RemoteEndPoint;
                OnLocalConnect?.Invoke(this, new DnsEndPoint(remoteIpEndPoint.Address.ToString(), remoteIpEndPoint.Port, remoteIpEndPoint.AddressFamily));
            }

            _serverSocket.Close();
        }
        private void AcceptConnections()
        {
            while (_serverStarted)
            {
                // Accept a connection
                var connection = new ConnectionInfo();

                var socket = _serverSocket.Accept();
                socket.ReceiveTimeout = ReceiveTimeout;
                socket.SendTimeout    = SendTimeout;

                connection.LocalSocket  = socket;
                connection.RemoteSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)
                {
                    SendTimeout    = SendTimeout,
                    ReceiveTimeout = ReceiveTimeout
                };

                // Create the thread for the receive
                connection.LocalThread = new Thread(ProcessLocalConnection)
                {
                    IsBackground = true
                };

                connection.LocalThread.Start(connection);
                OnLocalConnect?.Invoke(this, (IPEndPoint)socket.RemoteEndPoint);

                // Store the socket
                lock (_connections)
                {
                    _connections.Add(connection);
                }
            }

            _serverSocket.Close();
        }