Server
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
##Server $port=2021 $endpoint = new-object System.Net.IPEndPoint ([IPAddress]::Any,$port) $udpclient=new-Object System.Net.Sockets.UdpClient $port $content=$udpclient.Receive([ref]$endpoint) $convert=[Text.Encoding]::ASCII.GetString($content) $spli=$convert.Split("*") $user=$spli[0] $pass=$spli[1] if($user -eq "user" -and $pass -eq "pass") { Write-Host "Login" } else { Write-Host "No login" } $udpclient.Close() |
1 2 3 4 5 6 7 8 |
##Client $port=2021 $endpoint = new-object System.Net.IPEndPoint ([IPAddress]::Loopback,$port) $udpclient=new-Object System.Net.Sockets.UdpClient $val="user*pass" $b=[Text.Encoding]::ASCII.GetBytes($val.ToString()) $bytesSent=$udpclient.Send($b,$b.length,$endpoint) $udpclient.Close() |