Created
July 4, 2026 07:03
-
-
Save curtishall/70e32a57e99e5a191b40d63ba0c3a551 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $sw = [System.Diagnostics.Stopwatch]::StartNew() | |
| $client = New-Object System.Net.Sockets.TcpClient | |
| try { | |
| $client.Connect("10.101.240.5", 4518) | |
| Write-Host "Connected at $($sw.ElapsedMilliseconds) ms" | |
| $stream = $client.GetStream() | |
| $stream.ReadTimeout = 15000 | |
| $buf = New-Object byte[] 4096 | |
| try { | |
| $n = $stream.Read($buf, 0, $buf.Length) | |
| Write-Host "Server sent $n bytes at $($sw.ElapsedMilliseconds) ms" | |
| if ($n -gt 0) { [Text.Encoding]::ASCII.GetString($buf, 0, [Math]::Min($n, 200)) } | |
| } catch { | |
| Write-Host "No data within timeout at $($sw.ElapsedMilliseconds) ms" | |
| } | |
| Start-Sleep -Seconds 5 | |
| Write-Host "Still connected at $($sw.ElapsedMilliseconds) ms" | |
| } catch { | |
| Write-Host "Connect failed: $_" | |
| } finally { | |
| $client.Close() | |
| Write-Host "Closed at $($sw.ElapsedMilliseconds) ms" | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment