예제 #1
0
        public void Stop()
        {
            if (this.Listening)
            {
                this.Listening = false;
                try
                {
                    this.Server.Close();
                }
                catch
                {
                }

                this.Server         = null;
                this.SocketsManager = null;
                this.AcceptCallback = null;
            }
        }
예제 #2
0
        public SocketsListener(SocketsManager manager, string ip, int port, Revision revision, Crypto crypto)
        {
            this.SocketsManager = manager;
            this.Revision       = revision;
            this.Crypto         = crypto;

            this.AcceptCallback = new AsyncCallback(this.AcceptConnection);
            this.Server         = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            this.Server.NoDelay = true;
            this.Server.Bind(new IPEndPoint(IPAddress.Parse(ip), port));
            this.Server.Listen(1000);

            if (revision == Revision.None)
            {
                Logging.WriteLine("Listening for connections on port: " + port);
            }
            else
            {
                Logging.WriteLine("Listening for connections on port: " + port + " with specified revision: " + revision);
            }
        }