Ejemplo n.º 1
0
        ///<summary>Starts listening on the selected IP address and port.</summary>
        ///<exception cref="SocketException">There was an error while creating the listening socket.</exception>
        public async void Start()
        {
            try
            {
                ListenSocket = new TcpSocket(Address.AddressFamily, this.Secure);
                ListenSocket.Bind(new IPEndPoint(Address, Port));
                ListenSocket.Listen(50);

                SocketConnection socket = await ListenSocket.AcceptAsync();

                await this.OnAccept(socket);
            }
            catch (Exception ex)
            {
                Console.WriteLine("[WARN] " + ex.Message + "\r\n" + ex.StackTrace);
                this.Dispose();
                throw new SocketException();
            }
        }