Esempio n. 1
0
        /// <summary>
        ///     Terminates all active connections, sends out all remaining data and closes the socket.
        /// </summary>
        /// <param name="linger">Time to wait for the connections to close before forcefully terminating the socket.</param>
        public void Close(TimeSpan linger)
        {
            if (Closed)
            {
                return; // Do not raise an exception
            }
            if (linger != TimeSpan.Zero)
            {
                Socket.Options.Linger = linger;
            }

            Socket.ReceiveReady -= ReceiveMessage;
            TimerPoller.Stop();
            Poller.Stop();
            Socket.Close();
            foreach (var pair in Channels)
            {
                pair.Value.Destroy();
            }
            Channels.Clear();
            Closed = true;
        }
Esempio n. 2
0
 private void ReleaseUnmanagedResources()
 {
     TimerPoller.Stop();
     Close(TimeSpan.Zero);
 }