Contenidos
Ordenador que escucha y convierte el mensaje en mayúsculas (y se para cuando el cliente envía un 0)
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 |
##Server $ip = New-Object System.Net.IPEndPoint ([IPAddress]::Any,0) $udp = New-Object System.Net.Sockets.UdpClient 2020 do{ try { $content = $udp.Receive([ref]$ip) $recibido = [Text.Encoding]::ASCII.GetString($content) # Convertir a mayúsculas $recibido = $recibido.ToUpper() $mensaje = [Text.Encoding]::ASCII.GetBytes($recibido) $udp.Send($mensaje,$mensaje.length,$ip) | Out-Null } catch { } }while($recibido -ne 0) $udp.Close() |
Ordenador que manda el mensaje y recibe el mensaje convertido en mayúsculas
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
## Cliente $ip = New-Object System.Net.IPEndPoint ([IPAddress]::Loopback,2020) $udp = New-Object System.Net.Sockets.UdpClient $mensaje = [Text.Encoding]::ASCII.GetBytes('hola') $udp.Send($mensaje,$mensaje.length,$ip) | Out-Null $content = $udp.Receive([ref]$ip) [Text.Encoding]::ASCII.GetString($content) $udp.Close() |