bool ISocket.StartListening(SocketConnectionAccepted callback)
		{
			IPAddress any = IPAddress.Any;
			string ipString;
			if (Program.LaunchParameters.TryGetValue("-ip", out ipString) && !IPAddress.TryParse(ipString, out any))
			{
				any = IPAddress.Any;
			}
			this._isListening = true;
			this._listenerCallback = callback;
			if (this._listener == null)
			{
				this._listener = new TcpListener(any, Netplay.ListenPort);
			}
			try
			{
				this._listener.Start();
			}
			catch (Exception)
			{
				return false;
			}
			ThreadPool.QueueUserWorkItem(new WaitCallback(this.ListenLoop));
			return true;
		}
Пример #2
0
        bool ISocket.StartListening(SocketConnectionAccepted callback)
        {
            IPAddress address = IPAddress.Any;

            if (Program.LaunchParameters.TryGetValue("-ip", out string value) && !IPAddress.TryParse(value, out address))
            {
                address = IPAddress.Any;
            }
            _isListening      = true;
            _listenerCallback = callback;
            if (_listener == null)
            {
                _listener = new TcpListener(address, Netplay.ListenPort);
            }
            try
            {
                _listener.Start();
            }
            catch (Exception)
            {
                return(false);
            }
            Thread thread = new Thread(ListenLoop);

            thread.IsBackground = true;
            thread.Name         = "TCP Listen Thread";
            thread.Start();
            return(true);
        }
Пример #3
0
        bool Terraria.Net.Sockets.ISocket.StartListening(SocketConnectionAccepted callback)
        {
            bool flag;

            this._isListening      = true;
            this._listenerCallback = callback;
            if (this._listener == null)
            {
                this._listener = new TcpListener(IPAddress.Any, Netplay.ListenPort);
            }
            try
            {
                this._listener.Start();
                Thread t = new Thread(ListenLoop);
                t.IsBackground = true;
                t.Name         = "Listen Loop";
                t.Start();
                //ThreadPool.QueueUserWorkItem(new WaitCallback(this.ListenLoop));
                return(true);
            }
            catch
            {
                flag = false;
            }
            return(flag);
        }
Пример #4
0
        bool ISocket.StartListening(SocketConnectionAccepted callback)
        {
            var any = IPAddress.Any;

            if (Program.LaunchParameters.TryGetValue("-ip", out var ipString) && !IPAddress.TryParse(ipString, out any))
            {
                any = IPAddress.Any;
            }
            _isListening      = true;
            _listenerCallback = callback;
            if (_listener == null)
            {
                _listener = new TcpListener(any, Netplay.ListenPort);
            }
            try
            {
                _listener.Start();
            }
            catch (Exception)
            {
                return(false);
            }
            ThreadPool.QueueUserWorkItem(ListenLoop);
            return(true);
        }
Пример #5
0
        public bool StartListening(SocketConnectionAccepted callback)
        {
            _disconnect = false;

            var    any = IPAddress.Any;
            string ipString;

            if (Program.LaunchParameters.TryGetValue("-ip", out ipString) && !IPAddress.TryParse(ipString, out any))
            {
                any = IPAddress.Any;
            }

            _listener = new TcpListener(any, Netplay.ListenPort);

            try
            {
                this._listener.Start();
            }
            catch (Exception)
            {
                return(false);
            }

            (new System.Threading.Thread(ListenThread)).Start(callback);
            (new System.Threading.Thread(DrainThread)).Start();

            return(true);
        }
Пример #6
0
        bool ISocket.StartListening(SocketConnectionAccepted callback)
        {
            var    address = IPAddress.Any;
            string ipString;

            if (Program.LaunchParameters.TryGetValue("-ip", out ipString) && !IPAddress.TryParse(ipString, out address))
            {
                address = IPAddress.Any;
            }
            this._isListening      = true;
            this._listenerCallback = callback;
            if (this._listener == null)
            {
                this._listener = new TcpListener(address, Netplay.ListenPort);
            }
            try
            {
                this._listener.Start();
            }
            catch (Exception ex)
            {
                return(false);
            }

            ThreadPool.QueueUserWorkItem(new WaitCallback(this.ListenLoop));
            return(true);
        }
Пример #7
0
        bool ISocket.StartListening(SocketConnectionAccepted callback)
        {
            IPAddress address = IPAddress.Any;
            string    ipString;

            if (Program.LaunchParameters.TryGetValue("-ip", out ipString) && !IPAddress.TryParse(ipString, out address))
            {
                address = IPAddress.Any;
            }
            this._isListening      = true;
            this._listenerCallback = callback;
            if (this._listener == null)
            {
                this._listener = new TcpListener(address, Netplay.ListenPort);
            }
            try
            {
                this._listener.Start();
            }
            catch (Exception ex)
            {
                return(false);
            }
            new Thread(new ThreadStart(this.ListenLoop))
            {
                IsBackground = true,
                Name         = "TCP Listen Thread"
            }.Start();
            return(true);
        }
Пример #8
0
		public bool StartListening(SocketConnectionAccepted callback)
		{
			_disconnect = false;

			var any = IPAddress.Any;
			string ipString;
			if (Program.LaunchParameters.TryGetValue("-ip", out ipString) && !IPAddress.TryParse(ipString, out any))
			{
				any = IPAddress.Any;
			}

			_listener = new TcpListener(any, Netplay.ListenPort);

			try
			{
				this._listener.Start();
			}
			catch (Exception)
			{
				return false;
			}

			(new System.Threading.Thread(ListenThread)).Start(callback);
			(new System.Threading.Thread(DrainThread)).Start();

			return true;
		}
Пример #9
0
        bool ISocket.StartListening(SocketConnectionAccepted callback)
        {
            IPAddress any = IPAddress.Any;
            string    ipString;

            if (Program.LaunchParameters.TryGetValue("-ip", out ipString) && !IPAddress.TryParse(ipString, out any))
            {
                any = IPAddress.Any;
            }
            this._isListening      = true;
            this._listenerCallback = callback;
            if (this._listener == null)
            {
                this._listener = new TcpListener(any, Netplay.ListenPort);
            }
            try
            {
                this._listener.Start();
            }
            catch (Exception)
            {
                return(false);
            }

            _limiter = new Limiter(_config);

            new Thread(this.ListenLoop).Start();
            return(true);
        }
Пример #10
0
 public bool StartListening(SocketConnectionAccepted callback)
 {
     if (_server == null)
     {
         _server = new AsyncServerSocket(callback);
     }
     return(_server.Listen());
 }
Пример #11
0
 bool ISocket.StartListening(SocketConnectionAccepted callback)
 {
     this._isListening      = true;
     this._listenerCallback = callback;
     if (this._listener == null)
     {
         this._listener = new TcpListener(IPAddress.Any, Netplay.ListenPort);
     }
     try
     {
         this._listener.Start();
     }
     catch
     {
         return(false);
     }
     ThreadPool.QueueUserWorkItem(new WaitCallback(this.ListenLoop));
     return(true);
 }
Пример #12
0
        public bool StartListening(SocketConnectionAccepted callback)
        {
            var    any = IPAddress.Any;
            string ipString;

            if (Program.LaunchParameters.TryGetValue("-ip", out ipString) && !IPAddress.TryParse(ipString, out any))
            {
                any = IPAddress.Any;
            }

            _server = new SocketServer(any, Netplay.ListenPort);
            _server.SetConnectionAcceptedCallback((socket) =>
            {
                socket.NoDelay = true;

                var imp = new AsyncSocket(socket);
                Console.WriteLine(imp.GetRemoteAddress() + " is connecting...");
                callback(imp);
            });
            return(_server.Start());
        }
Пример #13
0
 public override bool StartListening(SocketConnectionAccepted callback)
 {
     return(false);
 }
Пример #14
0
 bool Terraria.Net.Sockets.ISocket.StartListening(SocketConnectionAccepted callback)
 {
     return(SocialAPI.Network.StartListening(callback));
 }
Пример #15
0
 public bool StartListening(SocketConnectionAccepted callback)
 {
     throw new NotImplementedException();
 }
		bool ISocket.StartListening(SocketConnectionAccepted callback)
		{
			return SocialAPI.Network.StartListening(callback);
		}
 public override bool StartListening(SocketConnectionAccepted callback)
 {
     this._acceptingClients           = true;
     this._connectionAcceptedCallback = callback;
     return(true);
 }
		public abstract bool StartListening(SocketConnectionAccepted callback);
Пример #19
0
 bool Terraria.Net.Sockets.ISocket.StartListening(SocketConnectionAccepted callback)
 {
     return SocialAPI.Network.StartListening(callback);
 }
 public override bool StartListening(SocketConnectionAccepted callback)
 {
     this._acceptingClients = true;
     this._connectionAcceptedCallback = callback;
     return true;
 }
 bool ISocket.StartListening(SocketConnectionAccepted callback)
 {
     #if Full_API
     this._isListening = true;
     this._listenerCallback = callback;
     if (this._listener == null)
     {
         this._listener = new TcpListener(IPAddress.Any, Terraria.Netplay.ListenPort);
     }
     try
     {
         this._listener.Start();
     }
     catch (Exception)
     {
         return false;
     }
     ThreadPool.QueueUserWorkItem(new WaitCallback(this.ListenLoop));
     #endif
     return true;
 }
Пример #22
0
 void HandleNewRequest(object sender, Socket newSocket)
 {
     SocketConnectionAccepted?.Invoke(this, newSocket);
 }
Пример #23
0
 public AsyncServerSocket(SocketConnectionAccepted callback)
 {
     _callback = callback;
 }
Пример #24
0
 bool ISocket.StartListening(SocketConnectionAccepted callback)
 {
     this._isListening = true;
     this._listenerCallback = callback;
     if (this._listener == null)
         this._listener = new TcpListener(IPAddress.Any, Netplay.ListenPort);
     try
     {
         this._listener.Start();
     }
     catch
     {
         return false;
     }
     ThreadPool.QueueUserWorkItem(new WaitCallback(this.ListenLoop));
     return true;
 }
Пример #25
0
 public abstract bool StartListening(SocketConnectionAccepted callback);
		public override bool StartListening(SocketConnectionAccepted callback)
		{
			return false;
		}