TCP UDP接続テストをコマンドベースで頑張りたいときに - ぶやかー

TCP Server

$tcp_srv = [System.Net.Sockets.TcpListener]50000
$tcp_srv.Start();

サーバの停止

$tcp_srv.Stop();

HTTP Server

python

python -m http.server 50000

TCP Client

Windows
Progressの表示がうざいので消しておく

$ProgressPreference="SilentlyContinue"
Test-NetConnection 172.16.200.5 -Port 50000

Windows PowershellでSocket使う

$tcp_clnt = New-Object System.Net.Sockets.tcpClient
$tcp_clnt.connect("172.16.200.5",50000)
$tcp_clnt.connected

UDP Client

Windows Powershell

$tc = New-Object System.Net.Sockets.UdpClient
$tc.Connect("172.16.200.5",50000)
$a = New-Object System.Text.ASCIIEncoding
$byte = $a.GetBytes("hello")
$tc.Send($byte,$byte.Length)
$tc.Close()

Windows PortQuery.exe

https://www.microsoft.com/en-us/download/details.aspx?id=17148
MS提供の簡易クライアント

PortQuery.exe -n 172.16.200.5 -e 50000 -p UDP

この記事を書いた人 Wrote this article

kmatsunuma@admin

TOP