TcpClient.Client.RemoteEndPoint.
就是这个属性,你仔细一些就可以找到了。
以后注意哦 :)

解决方案 »

  1.   

    RemoteEndPoint
    还要再检查一下你的题目里是要听盎IP还是请求方IP?TCPListener 和 TCPCLIENT 类里MSDN有很详细的介绍
    你看看就知道了。
    这几个类就是简化SOCKET操作的
    应用很简单的。
      

  2.   

    TcpClient.Client是protected的,怎么能访问呢?
      

  3.   

    TcpClient.Client.RemoteEndPoint.
    就是这个属性,你仔细一些就可以找到了。
    以后注意哦 :)
      

  4.   

    ???Protected属性访问不了啊!!!
      

  5.   

    // This derived class demonstrates the use of three protected methods belonging to the TcpClient class
    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);
    }}
      

  6.   

    具体这样实现
    public class MyTcpClient:TcpClient
    {
       public string getip()
       {
          return this.Client.RemoteEndPoint.ToString();
       }
    }
      

  7.   

    就是
    TcpClient.RemoteEndPoint这个属性.
    将它显示为字符串为:
    xxx.xxx.xxx.xxx:yyyy
    其中:前面的就是远程的ip地址,后面为端口。
    =====================================
      

  8.   

    拜托各位,能不能仔细看题目,这个TcpClient是从TcpListener的函数AcceptTcpClient()返回的,我也不能派生