icinga-powershell-framework/lib/web/New-IcingaTCPSocket.psm1
2020-03-24 12:42:14 +01:00

19 lines
347 B
PowerShell

function New-IcingaTCPSocket()
{
param(
[int]$Port = 0,
[switch]$Start = $FALSE
);
if ($Port -eq 0) {
throw 'Please specify a valid port to open a TCP socket for';
}
$TCPSocket = [System.Net.Sockets.TcpListener]$Port;
if ($Start) {
$TCPSocket.Start();
}
return $TCPSocket;
}