maciejkapaste-backup-2023-2.../pastes/paste_1f338f.txt
2023-12-31 18:17:29 +01:00

27 lines
720 B
Plaintext

#
# ID: 1f338f
# Nazwa: Python-PowerShell Socket Connection
# Opis: PowerShell
# Publiczny: 0
# Data utworzenia/ostatniej edycji (UTC): 2023-10-18 21:15:54
#
$socketHost = "127.0.0.1"
$socketPort = "53588"
$tcpConnection = New-Object System.Net.Sockets.TcpClient($socketHost, $socketPort)
$tcpStream = $tcpConnection.GetStream()
$reader = New-Object System.IO.StreamReader($tcpStream)
while ($tcpConnection.Connected) {
while ($tcpStream.DataAvailable -or $reader.Peek() -ne -1 ) {
$response = $reader.ReadLine()
Write-Output "Received:"
Write-Output "$response"
}
start-sleep -Milliseconds 500
}
$reader.Close()
$tcpConnection.Close()