示例#1
0
 public void ServerTest()
 {
     Server server = new Server(new Listener(new IPEndPoint(IPAddress.Any, 8888)), new ClientsManager());
     server.Start();
     Thread.Sleep(1000);
     server.Stop();
 }
示例#2
0
        static void Main(string[] args)
        {
            IPEndPoint endPoint = new IPEndPoint(IPAddress.Parse("192.168.56.1"), 8008);
            Listener listener = new Listener(endPoint);
            ClientsManager clientManager = new ClientsManager();
            Server server = new Server(listener, clientManager);
            server.Start();

            Console.WriteLine("Hosted on {0}\nPress any key to stop the server.", endPoint.ToString());
            Console.ReadKey();
        }
示例#3
0
        static void Main(string[] args)
        {
            String strHostName = Dns.GetHostName();
            IPHostEntry iphostentry = Dns.GetHostByName(strHostName);

            IPEndPoint endPoint = new IPEndPoint(iphostentry.AddressList.First(), 8008);
            Listener listener = new Listener(endPoint);
            ClientsManager clientManager = new ClientsManager();
            Server server = new Server(listener, clientManager);
            server.Start();

            Console.WriteLine("Hosted on {0}\nPress any key to stop the server.", endPoint.ToString());
            Console.ReadKey();
        }
示例#4
0
        static void Main(string[] args)
        {
            DesktopClient.JsonProtocol protocol = new DesktopClient.JsonProtocol();
            Socket desktopSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            IPEndPoint endPoint = new IPEndPoint(IPAddress.Parse("192.168.56.1"), 8008);

            Listener listener = new Listener(endPoint);
            ClientsManager clientManager = new ClientsManager();
            Server server = new Server(listener, clientManager);
            server.Start();

            protocol.Connect(endPoint, ref desktopSocket);

            protocol.SendObject(new Command(Command.Commands.Exit, string.Empty), desktopSocket);

            Command command = protocol.ReadObject(desktopSocket, typeof(Command)) as Command;
            server.Stop();
        }
示例#5
0
 public void ServerWrongPort()
 {
     Server server = new Server(new Listener(new IPEndPoint(IPAddress.Any, -1)), new ClientsManager());
 }