Contenidos
Servidor (recibe el nombre del usuario y responde el contenido HTML)
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 cliete</html>") $udp.Send($mensaje,$mensaje.length,$ip) | Out-Null } $udp.Close() |
Cliente (enviar el nombre del usuario y abre el fichero HTML que envía el servidor)
1 2 3 4 5 6 7 8 9 10 11 |
$ip = New-Object System.Net.IPEndPoint ([IPAddress](Resolve-DnsName localhost).IP4Address,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 |