Inheritance: global::Terraria.Net.Sockets.ISocket
Exemplo n.º 1
0
        private void ListenThread(object state)
        {
            var callback = (SocketConnectionAccepted)state;

            try
            {
                while (!_disconnect)
                {
                    _listener.Server.Poll(500000, SelectMode.SelectRead);

                    if (_disconnect)
                    {
                        break;
                    }

                    // Accept new clients
                    while (_listener.Pending())
                    {
                        var socket = _listener.AcceptSocket();
                        var imp    = new PoolSocket(socket);
                        Console.WriteLine(imp.GetRemoteAddress() + " is connecting...");
                        callback(imp);
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine($"{nameof(ListenThread)} terminated with exception\n{ex}");
            }
        }
Exemplo n.º 2
0
		private void ListenThread(object state)
		{
			var callback = (SocketConnectionAccepted)state;

			try
			{
				while (!_disconnect)
				{
					_listener.Server.Poll(500000, SelectMode.SelectRead);

					if (_disconnect) break;

					// Accept new clients
					while (_listener.Pending())
					{
						var socket = _listener.AcceptSocket();
						var imp = new PoolSocket(socket);
						Console.WriteLine(imp.GetRemoteAddress() + " is connecting...");
						callback(imp);
					}
				}
			}
			catch (Exception ex)
			{
				Console.WriteLine($"{nameof(ListenThread)} terminated with exception\n{ex}");
			}
		}