public void Close() { if (m_Socket == null) { return; } lock (m_SendQueue) { m_SendQueue.Clear(); } m_ReceiveBuffer.SetLength(0); try { m_Socket.Shutdown(SocketShutdown.Both); } catch (Exception e) { if (m_Handler != null) { m_Handler.OnExceptionCaught(this, e); } } m_Socket.Close(); m_Socket = null; if (m_Handler != null) { m_Handler.OnClosed(this); } }