2014-07-09 2 views
0

나는 어떤 IP 주소 (변경 될 수 있습니다) 연결할 수와PowerShell을 소켓 - 서버에 연결된 IP-주소는

$endpoint = new-object System.Net.IPEndPoint ([system.net.ipaddress]::any, $port) 
    $listener = new-object System.Net.Sockets.TcpListener $endpoint 

모든 클라이언트가 소켓 서버를 시작했다.
는 어떻게 연결 후 연결된 클라이언트의 IP-요지를받을 수 있나요하고 받아 들여졌다 :

if ($listener.Pending()) { 
     $client = $listener.AcceptTcpClient() 
     $stream = $client.GetStream(); 
     $writer = New-Object System.IO.StreamWriter $stream 
     $writer.AutoFlush = $true 
     ... 
    } 

불행하게도 $ client.IPAddress() (오류) 또는 $ client.IPAddress (아무것도)하지 존재합니까 미리 감사드립니다!

답변

1

당신은 그것을 통해 얻을 수 있습니다 $client.Client.RemoteEndPoint

+0

고마워요 - 그게 전부예요 :) – gooly

관련 문제