From afec954d35454d8cacb09f7f5cc9be42c2d81fe9 Mon Sep 17 00:00:00 2001 From: Lord Hepipud Date: Tue, 22 Oct 2019 20:05:43 +0200 Subject: [PATCH] Add tool function to close and flush TCP connections --- lib/core/tools/Close-IcingaTcpConnection.psm1 | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 lib/core/tools/Close-IcingaTcpConnection.psm1 diff --git a/lib/core/tools/Close-IcingaTcpConnection.psm1 b/lib/core/tools/Close-IcingaTcpConnection.psm1 new file mode 100644 index 0000000..65b532a --- /dev/null +++ b/lib/core/tools/Close-IcingaTcpConnection.psm1 @@ -0,0 +1,14 @@ +function Close-IcingaTcpConnection() +{ + param( + $TcpClient + ); + + if ($null -eq $TcpClient) { + return; + } + + $TcpClient.Close(); + $TcpClient.Dispose(); + $TcpClient = $null; +}