public void ServerTest() { Server server = new Server(new Listener(new IPEndPoint(IPAddress.Any, 8888)), new ClientsManager()); server.Start(); Thread.Sleep(1000); server.Stop(); }
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(); }
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(); }
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(); }
public void ServerWrongPort() { Server server = new Server(new Listener(new IPEndPoint(IPAddress.Any, -1)), new ClientsManager()); }