Exemplo n.º 1
0
        public void StartListning()
        {
            IPEndPoint localEndPoint = new IPEndPoint(_localAddress, _localPort);

            _socket = new Socket(_localAddress.AddressFamily, _socketType, _protocolType);
            _socket.Bind(localEndPoint);
            _socket.Blocking = false;
            _socket.Listen(1);


            _listeningThread = new ThreadWraper(() =>
            {
                try
                {
                    Socket stemp = _socket.Accept();

                    Client client = new Client(stemp, _protocolType, _socketType);

                    Program.StatusMessage("Client connected");

                    client.StartDecoding(DecodeMessage);

                    _client.Add(client);
                }
                catch (SocketException e)
                {
                }
            });

            _listeningThread.Start();
        }