Servidor
1 2 3 4 5 6 7 8 9 10 11 12 |
$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)) $usuario if($usuario -eq "juanito") { $mensaje = [Text.Encoding]::ASCII.GetBytes("<html>hola clie</html>") $udp.Send($mensaje,$mensaje.length,$ip) | Out-Null } $udp.Close() |
Cliente
1 2 3 4 5 6 7 8 9 10 11 12 13 |
$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)) | Out-File web2.html start chrome web2.html $udp.Close() |