Servidor
1 2 3 4 5 6 7 8 9 |
$ip = New-Object System.Net.IPEndPoint ([IPAddress]::Loopback,0) $udp = New-Object System.Net.Sockets.UdpClient 2020 $usuario = [Text.Encoding]::ASCII.GetString($udp.Receive([ref]$ip)) $mensaje = [Text.Encoding]::ASCII.GetBytes("Hola cliente") $udp.Send($mensaje,$mensaje.length,$ip) | Out-Null $udp.Close() |
Cliente
1 2 3 4 5 6 7 8 9 10 11 12 |
$ip = New-Object System.Net.IPEndPoint ([IPAddress]::Loopback,2020) $udp = New-Object System.Net.Sockets.UdpClient $usuario = Read-Host "Introduzca nombre de usuario: " $mensaje = [Text.Encoding]::ASCII.GetBytes($usuario) $udp.Send($mensaje,$mensaje.length,$ip) | Out-Null [Text.Encoding]::ASCII.GetString($udp.Receive([ref]$ip)) $udp.Close() |