icinga-powershell-framework/lib/web/New-IcingaTCPSocket.psm1

20 lines
347 B
PowerShell
Raw Normal View History

2020-03-24 07:42:14 -04:00
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;
}