Servidor
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
$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)) if ($usuario -eq "juanito") { "<html>hola juanito</html>" | out-file juanito.html start chrome juanito.html } else { "<html>no eres juanito</html>" | out-file juanitono.html start chrome juanitono.html } $udp.Close() |
Cliente
1 2 3 4 5 6 7 8 9 |
$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 $udp.Close() |