我先创建了一个套接字
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???
请指点~~~~~~~~~~~
解决方案 »
- 不同类型的对象,相同属性,互相转换
- c#中datagrid绑定后怎么不显示数据了呢(数据源中有数据),只显示表头
- c#gdi如何让圆在屏幕上随机移动,当圆接触到边缘时就改变方向
- udp协议无法收到服务器消息????
- Label用法
- C# 如何从数据库表中查询一个字段到listBox1中显示?
- ******ASP.NET回传值是否会被用户修改********
- 请问这俩个时间怎么比较大小?
- 高分:如何使控件响应不刷新页面?(不是回调)
- threading.timer 线程安全问题
- 小女子急求教:学习ASP.NET 建立项目时出错,怎办????各位哥哥请指教
- proc.StartInfo.FileName = @"rar.exe"; 请问:@啥意思?
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 ;