// Default constructor public OSServer(Settings intSettings) { exceptionthrown = false; // First we set up our mutex and semaphore mutex = new Mutex(); numconnections = 0; // Then we create our stack of read sockets socketpool = new OSAsyncEventStack(Convert.ToInt32(intSettings.NumConnect)); // Now we create enough read sockets to service the maximum number of clients // that we will allow on the server // We also assign the event handler for IO Completed to each socket as we create it // and set up its buffer to the right size. // Then we push it onto our stack to wait for a client connection for (Int32 i = 0; i < Convert.ToInt32(intSettings.NumConnect); i++) { SocketAsyncEventArgs item = new SocketAsyncEventArgs(); item.Completed += new EventHandler<SocketAsyncEventArgs>(OnIOCompleted); item.SetBuffer(new Byte[Convert.ToInt32(intSettings.BufferSize)], 0, Convert.ToInt32(intSettings.BufferSize)); socketpool.Push(item); } // Create the Mllp Helper object here hl7 hl7 = new hl7(); }
// This method closes the read socket and gets rid of our user token associated with it private void CloseReadSocket(OSUserToken token, SocketAsyncEventArgs readSocket) { token.Dispose(); // Decrement the counter keeping track of the total number of clients connected to the server. Interlocked.Decrement(ref numconnections); // Put the read socket back in the stack to be used again socketpool.Push(readSocket); }
// Default constructor public OSServer() { exceptionthrown = false; // First we set up our mutex and semaphore mutex = new Mutex(); numconnections = 0; // Then we create our stack of read sockets socketpool = new OSAsyncEventStack(DEFAULT_MAX_CONNECTIONS); // Now we create enough read sockets to service the maximum number of clients // that we will allow on the server // We also assign the event handler for IO Completed to each socket as we create it // and set up its buffer to the right size. // Then we push it onto our stack to wait for a client connection for (Int32 i = 0; i < DEFAULT_MAX_CONNECTIONS; i++) { SocketAsyncEventArgs item = new SocketAsyncEventArgs(); item.Completed += new EventHandler <SocketAsyncEventArgs>(OnIOCompleted); item.SetBuffer(new Byte[DEFAULT_BUFFER_SIZE], 0, DEFAULT_BUFFER_SIZE); socketpool.Push(item); } }
// Default constructor public OSServer() { exceptionthrown = false; // First we set up our mutex and semaphore mutex = new Mutex(); numconnections = 0; // Then we create our stack of read sockets socketpool = new OSAsyncEventStack(DEFAULT_MAX_CONNECTIONS); // Now we create enough read sockets to service the maximum number of clients // that we will allow on the server // We also assign the event handler for IO Completed to each socket as we create it // and set up its buffer to the right size. // Then we push it onto our stack to wait for a client connection for (Int32 i = 0; i < DEFAULT_MAX_CONNECTIONS; i++) { SocketAsyncEventArgs item = new SocketAsyncEventArgs(); item.Completed += new EventHandler<SocketAsyncEventArgs>(OnIOCompleted); item.SetBuffer(new Byte[DEFAULT_BUFFER_SIZE], 0, DEFAULT_BUFFER_SIZE); socketpool.Push(item); } }