/// <summary> /// Create a new Server object /// </summary> /// <param name="port">The port you want to use</param> public Server(int port) { //Initialize the array with a maximum of the MaxClients from the config file. client = new Client[Properties.Settings.Default.MaxNumberOfClients]; //Create a new Listener object listener = new Listener(port); listener.userAdded += new ConnectionEvent(listener_userAdded); listener.Start(); //Create the readers and writers. readStream = new MemoryStream(); writeStream = new MemoryStream(); reader = new BinaryReader(readStream); writer = new BinaryWriter(writeStream); //Set the singleton to the current object Server.singleton = this; }
static void Main(string[] args) { //Display the current settings to the window WriteSettings(); //Try to start a new server using the default port in the config file. try { Server server = new Server(Properties.Settings.Default.Port); while (true) { Thread.Sleep(1000); } } catch (Exception e) { Console.WriteLine(e.ToString()); } Console.ReadKey(); }