public static void Main(string[] args) { // Before the app starts, let's build strings for you to use the console. BuildStringsForClientConsole(); // Get settings and connection info. ConfigFileHandler configHandler = new ConfigFileHandler(); // Start the log writer. testWriter = new TestFileWriter(configHandler.saveDirectory); // Create one object with a lot of settings, to pass to SocketClient. SocketClientSettings socketClientSettings = new SocketClientSettings(configHandler.remoteEndPoint, configHandler.totalNumberOfClientConnectionsToRun, configHandler.numberOfReceivedMessagesPerConnection, Program.maxSimultaneousConnectOps, configHandler.maximumNumberOfSimultaneousClientConnections, Program.receivePrefixLength, configHandler.testBufferSize, Program.sendPrefixLength, Program.opsToPreAlloc); // Build the arrays of messages that will be sent, and pass them // to the SocketClient object in a stack of arrays. MessageArrayController messageArrayController = new MessageArrayController(configHandler); Stack <OutgoingMessageHolder> stackOfOutgoingMessages = messageArrayController.CreateMessageStack(); // Create the object that will do most of the work. SocketClient socketClient = new SocketClient(socketClientSettings); socketClient.GetMessages(stackOfOutgoingMessages); // Interact with the console. HandleConsoleInteraction(configHandler, socketClient); }
//__END variables for real app____________________________________________ //____________________________________________________________________________ // Create uninitialized SocketClient instance. public SocketClient(SocketClientSettings theSocketClientSettings) { if (Program.watchProgramFlow == true) //for testing { Program.testWriter.WriteLine("SocketClient constructor"); } this.socketClientSettings = theSocketClientSettings; this.prefixHandler = new PrefixHandler(); this.messageHandler = new MessageHandler(); this.messagePreparer = new MessagePreparer(); this.bufferManager = new BufferManager(this.socketClientSettings.BufferSize * this.socketClientSettings.NumberOfSaeaForRecSend * this.socketClientSettings.OpsToPreAllocate, this.socketClientSettings.BufferSize * this.socketClientSettings.OpsToPreAllocate); this.poolOfRecSendEventArgs = new SocketAsyncEventArgsPool(this.socketClientSettings.NumberOfSaeaForRecSend); this.poolOfConnectEventArgs = new SocketAsyncEventArgsPool(this.socketClientSettings.MaxConnectOps); this.theMaxConnectionsEnforcer = new Semaphore(this.socketClientSettings.MaxConnections, this.socketClientSettings.MaxConnections); this.counterForLongTest = new Semaphore(this.socketClientSettings.ConnectionsToRun, this.socketClientSettings.ConnectionsToRun); Init(); }