mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2025-12-21 07:10:15 -05:00
20 lines
347 B
PowerShell
20 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;
|
||
|
|
}
|