Hi,
these UDP client and server and simply used for testing if a specific UDP port is open
This is the server side. It listens at port 4444
1 2 3 4 5 6 7 8 9 | # Server$iPort = 4444$Listen = New-Object System.Net.IPEndPoint ([IPAddress]::Any , $port)$oSocket = New-Object System.Net.Sockets.UdpClient($iPort) while($true) { $aContent = $oSocket.Receive([ref]$Listen) [Text.Encoding]::ASCII.GetString($aContent) }$oSocket.Close() |
And the client side
1 2 3 4 5 6 | # Client$iPort = 4444$sSendToHost="localhost"$oSocket = New-Object System.Net.Sockets.UdpClient$aMessage=[System.Text.Encoding]::ASCII.GetBytes("TEST 1234")$oSocket.Send($aMessage ,$aMessage.Length,$sSendToHost,$iPort) |
Michael