private/Send-UDPMessage.ps1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
Function Send-UDPMessage { <# .SYNOPSIS Sends a datagram using the specified UDP Client .DESCRIPTION Internal function. This function will send a datagram using the specified UDP Client. .EXAMPLE Send-UdpMessage -UdpWriter $Writer -Datagram $Message Sends the datagram, or byte array, $Message using the specified UDP Client $writer. .OUTPUTS None #> [CmdletBinding()] param ( # TCPWriter object, that is already connected to the TCP server. [Parameter(Mandatory = $true, HelpMessage = 'UDPClient object, that is already connected to the TCP server')] [ValidateNotNullOrEmpty()] [System.Net.Sockets.UdpClient] $UdpClient, # Byte array containing the datagram to be sent. [Parameter(Mandatory = $true, HelpMessage = 'Byte array containing the datagram to be sent')] [ValidateNotNullOrEmpty()] [byte[]] $Datagram ) Write-Verbose -Message ([Text.Encoding]::ASCII.GetString($Datagram)) $null = $UdpClient.Send($Datagram, $Datagram.Length) } |