C# 如何正确关闭 socket 连接释放占用的端口?

var socket = this.LocalClient;
                if (socket != null)
                {
                    try { socket.Shutdown(SocketShutdown.Both); } catch { }
                    try { socket.Close(); } catch { }
                    try { socket.Dispose(); } catch { }
                }

 

posted on 2023-03-06 00:02  空明流光  阅读(2809)  评论(0编辑  收藏  举报

导航