public static void CloseCurrent(this Socket socket) { if (socket != null) { ExceptionUtil.EatException(() => socket.Close(10000)); } }
public static void ShutDownCurrent(this Socket socket) { if (socket != null) { ExceptionUtil.EatException(() => socket.Shutdown(SocketShutdown.Both)); socket.CloseCurrent(); } }
public static void DisposeCurrent(this SocketAsyncEventArgs e, EventHandler <SocketAsyncEventArgs> Completed) { if (e != null) { ExceptionUtil.EatException(() => { e.Completed -= Completed; e.AcceptSocket = null; e.Dispose(); }); } }
/// <summary> /// 释放全部连接 /// </summary> public static void DisposeConn() { lock (_connectionMultiplexerCache) { ExceptionUtil.EatException(() => { foreach (var item in _connectionMultiplexerCache.Values) { ExceptionUtil.EatException(() => item.Dispose()); } _connectionMultiplexerCache.Clear(); }); } }