Example #1
0
 public ConnectionServicer(Socket clientSocket, RecServiceState state, TimeSpan readTimeout, TimeSpan writeTimeout, CancellationToken cancellationToken)
 {
     m_socket            = clientSocket;
     m_state             = state;
     m_readTimeout       = readTimeout;
     m_writeTimeout      = writeTimeout;
     m_cancellationToken = cancellationToken;
 }
Example #2
0
        public TcpRecService(IMalTrainingDataLoaderFactory trainingDataLoaderFactory, int portNumber)
        {
            m_state = new RecServiceState(trainingDataLoaderFactory);

            try
            {
                Listener = new TcpListener(new IPEndPoint(IPAddress.Any, portNumber));
            }
            catch
            {
                m_state.Dispose();
                throw;
            }
        }
Example #3
0
        /// <summary>
        /// Stops listening for new connections and waits for running connection servicers to finish,
        /// up to the time given by connectionDrainTimeout. After that, a cancellation is issued
        /// to the connection servicers but they are not waited on.
        /// Ideally, potentially long-running operations would periodically check for cancellation.
        /// But since the program is shutting down anyway, it doesn't really matter.
        ///
        /// Once the service is stopped, it cannot be started again.
        /// </summary>
        /// <param name="connectionDrainTimeout"></param>
        public void Stop(TimeSpan connectionDrainTimeout)
        {
            if (m_state == null)
            {
                return; // already stopped
            }

            // Only stop if the service got started.
            if (m_stopper != null)
            {
                StopService(connectionDrainTimeout);
            }

            // Make the memory available for garbage collection
            m_state = null;
        }
 public ConnectionServicer(TcpClient client, RecServiceState state)
 {
     Client = client;
     State = state;
 }
Example #5
0
 // Must not block
 public TcpRecService(int portNumber, IMalTrainingDataLoaderFactory trainingDataLoaderFactory, MalTrainingData trainingData, IDictionary <int, IList <int> > prereqs)
 {
     m_portNumber = portNumber;
     m_state      = new RecServiceState(trainingDataLoaderFactory, trainingData, prereqs);
 }