static void Main(String[] args) { // Just used to calculate # of received transmissions at the end. startingTid = mainTransMissionId; // Before the app starts, let's build strings for you to use the console. BuildStringsForServerConsole(); // Create List<T> to hold data, unless we are running a long test, which // would create too much data to store in a list. if (runLongTest == false) { listOfDataHolders = new List <DataHolder>(); } //Create a log file writer, so you can see the flow easily. //It can be printed. Makes it easier to figure out complex program flow. //The log StreamWriter uses a buffer. So it will only work right if you close //the server console properly at the end of the test. testWriter = new TestFileWriter(); try { // Get endpoint for the listener. IPEndPoint localEndPoint = new IPEndPoint(IPAddress.Any, port); WriteInfoToConsole(localEndPoint); //This object holds a lot of settings that we pass from Main method //to the SocketListener. In a real app, you might want to read //these settings from a database or windows registry settings that //you would create. SocketListenerSettings theSocketListenerSettings = new SocketListenerSettings (maxNumberOfConnections, excessSaeaObjectsInPool, backlog, maxSimultaneousAcceptOps, receivePrefixLength, testBufferSize, sendPrefixLength, opsToPreAlloc, localEndPoint); //instantiate the SocketListener. SocketListener socketListener = new SocketListener(theSocketListenerSettings); ManageClosing(socketListener); } catch (Exception ex) { Console.WriteLine("Error: " + ex.Message); } finally { // close the stream for test file writing try { testWriter.Close(); } catch { Console.WriteLine("Could not close log properly."); } } }
// public static ILogger Logger = new TestFileWriter(); static void Main(String[] args) { // Just used to calculate # of received transmissions at the end. startingTid = mainTransMissionId; // Before the app starts, let's build strings for you to use the console. BuildStringsForServerConsole(); // Create List<T> to hold data, unless we are running a long test, which // would create too much data to store in a list. if (runLongTest == false) { listOfDataHolders = new List<DataHolder>(); } //Create a log file writer, so you can see the flow easily. //It can be printed. Makes it easier to figure out complex program flow. //The log StreamWriter uses a buffer. So it will only work right if you close //the server console properly at the end of the test. testWriter = new TestFileWriter(); try { // Get endpoint for the listener. var localEndPoint = new IPEndPoint(IPAddress.Any, port); WriteInfoToConsole(localEndPoint); //This object holds a lot of settings that we pass from Main method //to the SocketListener. In a real app, you might want to read //these settings from a database or windows registry settings that //you would create. var theSocketListenerSettings = new SocketListenerSettings (maxNumberOfConnections, excessSaeaObjectsInPool, backlog, maxSimultaneousAcceptOps, receivePrefixLength, testBufferSize, sendPrefixLength, opsToPreAlloc, localEndPoint, true, true); //instantiate the SocketListener. var socketListener = new SocketListener(theSocketListenerSettings, testWriter); socketListener.Init(); socketListener.StartListen(); ManageClosing(socketListener); } catch (Exception ex) { Console.WriteLine("Error: " + ex.Message); } finally { // close the stream for test file writing try { testWriter.Close(); } catch { Console.WriteLine("Could not close log properly."); } } }