コード例 #1
0
ファイル: Listener.cs プロジェクト: TheGhostGroup/reGW2
        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;
        }
コード例 #2
0
 public Client(Socket socket)
 {
     Socket               = socket;
     threadExecutor       = new ThreadExecutor();
     threadExecutor.Tick += ReceiveTick;
 }
コード例 #3
0
 public Client(IPAddress address, int port)
 {
     Socket               = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
     threadExecutor       = new ThreadExecutor();
     threadExecutor.Tick += ReceiveTick;
 }