TcpClient.Client.RemoteEndPoint.
就是这个属性,你仔细一些就可以找到了。
以后注意哦 :)
就是这个属性,你仔细一些就可以找到了。
以后注意哦 :)
解决方案 »
- 现在有一金额¥2048,请写段程序将此金额转换成二千零四十八
- 如何将保存RGB值的数组转化成一张BMP图像并且显示
- treeview空间的属性问题
- global.asax文件中的serialPort
- 如何把byte[]转化成结构体啊!!!!!!
- 关于HttpWebRequest的问题,不解
- 请问高手:如何在安装程序中让用户输入一定的信息并保存起来。
- Web页面里水晶报表如何对齐?
- WPF自定义MenuItem样式后一些问题
- 为什么VC2008装完以后有.net compact framework而不是一般的.net framework
- 如何让datagrid对任意Access数据库日期时间显示完整的年月日 时分秒
- 哪里有三层体现架构的例子?
还要再检查一下你的题目里是要听盎IP还是请求方IP?TCPListener 和 TCPCLIENT 类里MSDN有很详细的介绍
你看看就知道了。
这几个类就是简化SOCKET操作的
应用很简单的。
就是这个属性,你仔细一些就可以找到了。
以后注意哦 :)
public class MyTcpClientDerivedClass : TcpClient
{ // Constructor for the derived class.
public MyTcpClientDerivedClass() : base()
{
public void UsingProtectedMethods()
{ // Uses the protected 'Active' property belonging to the TcpClient base class
// to determine if a connection is established.
if (this.Active){
// Calls the protected 'Client' property belonging to the TcpClient base class.
Socket s = this.Client;
// Uses the Socket returned by Client to set an option that is not available using TcpClient.
s.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Broadcast, 1);
}
// To free all resources, calls the protected virtual method Dispose belonging to the TcpClient base class.
this.Dispose(true);
GC.SuppressFinalize(this);
}}
public class MyTcpClient:TcpClient
{
public string getip()
{
return this.Client.RemoteEndPoint.ToString();
}
}
TcpClient.RemoteEndPoint这个属性.
将它显示为字符串为:
xxx.xxx.xxx.xxx:yyyy
其中:前面的就是远程的ip地址,后面为端口。
=====================================