private void Release(Socket socket) { try { socket.Shutdown(SocketShutdown.Both); } catch (SocketException ex) { ExceptionHandler.Trace(ex); } try { socket.Close(); SocketPool.ReleaseSocket(socket); } catch (SocketException ex) { ExceptionHandler.Trace(ex); } }
public virtual void Dispose(bool flush) { if (mSocket == null || mDisposing) { return; } mDisposing = true; //##PACKET## Logout Thread.Sleep(100); if (flush) { flush = Flush(); } try { mSocket.Shutdown(SocketShutdown.Both); } catch (SocketException ex) { ExceptionHandler.Trace(ex); } try { mSocket.Close(); SocketPool.ReleaseSocket(mSocket); } catch (SocketException ex) { ExceptionHandler.Trace(ex); } mSocket = null; mBuffer = null; mRecvBuffer = null; mOnReceive = null; mOnSend = null; mRunning = false; mDisposed.Enqueue(this); if (!mSendQueue.IsEmpty) { lock (mSendQueue) mSendQueue.Clear(); } }