时间:2010-07-23 13:36:55

标签: c# sockets

3 个答案:

答案 0 :(得分:3)

答案 1 :(得分:2)

为了获得实际的IP地址:

// Using the RemoteEndPoint property.
Console.WriteLine (
"I am connected to " + IPAddress.Parse (((IPEndPoint)s.RemoteEndPoint).Address.ToString ()) + 
"on port number " + ((IPEndPoint)s.RemoteEndPoint).Port.ToString ());

// Using the LocalEndPoint property.
Console.WriteLine (
"My local IpAddress is :" + IPAddress.Parse (((IPEndPoint)s.LocalEndPoint).Address.ToString ()) +
"I am connected on port number " + ((IPEndPoint)s.LocalEndPoint).Port.ToString ());

取自msdn网站:

答案 2 :(得分:0)