我先创建了一个套接字
ListenSocket=new Socket (ipAddress.AddressFamily,SocketType.Stream ,ProtocolType.Tcp );
用该套接字去侦听特定端口,用ListenSocket.BeginAccept()得到一连接请求后,
再用ListenSocket.EndAccept()结束该连接,
那么我庐怎样去获得发出该请求的主机IP???
请指点~~~~~~~~~~~
ListenSocket=new Socket (ipAddress.AddressFamily,SocketType.Stream ,ProtocolType.Tcp );
用该套接字去侦听特定端口,用ListenSocket.BeginAccept()得到一连接请求后,
再用ListenSocket.EndAccept()结束该连接,
那么我庐怎样去获得发出该请求的主机IP???
请指点~~~~~~~~~~~
Console.WriteLine("I am connected to ")
Console.WriteLine(IPAddress.Parse(CType(s.RemoteEndPoint, IPEndPoint).Address.ToString()))
Console.WriteLine("on port number ")
Console.WriteLine(CType(s.RemoteEndPoint, IPEndPoint).Port.ToString())' Using the LocalEndPoint property.
Console.WriteLine("My local IpAddress is :")
Console.WriteLine(IPAddress.Parse(CType(s.LocalEndPoint, IPEndPoint).Address.ToString()))
Console.WriteLine("I am connected on port number ")
Console.WriteLine(CType(s.LocalEndPoint, IPEndPoint).Port.ToString())
EndPoint tempRemoteEP =sock.RemoteEndPoint ;
IPEndPoint tempRemoteIP = ( IPEndPoint ) tempRemoteEP ;
//获取请求的远程计算机名称
IPHostEntry host = Dns.GetHostByAddress
( tempRemoteIP.Address ) ;
string sHostName = host.HostName ;