Esempio n. 1
0
        public Listener(IPAddress address, int port)
        {
            try
            {
                endPoint = new IPEndPoint(address, port);
                socket   = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                socket.Bind(endPoint);
            }
            catch (SocketException ex)
            {
                if (ex.SocketErrorCode == SocketError.AddressAlreadyInUse)
                {
                    Console.Write("Address and/or port is already in use.");
                    Console.ReadKey(true);
                    Environment.Exit(1);
                }
            }

            threadExecutor       = new ThreadExecutor();
            threadExecutor.Tick += ListenTick;
        }
Esempio n. 2
0
 public Client(Socket socket)
 {
     Socket               = socket;
     threadExecutor       = new ThreadExecutor();
     threadExecutor.Tick += ReceiveTick;
 }
Esempio n. 3
0
 public Client(IPAddress address, int port)
 {
     Socket               = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
     threadExecutor       = new ThreadExecutor();
     threadExecutor.Tick += ReceiveTick;
 }