to:如何获取客户端IP地址
IPHostEntry ip=Dns.GetHostByName(textBox1.Text);         //textBox1.Text是客户端主机名         IPAddress[] ipp=ip.AddressList;
for(int i=0;i<=ipp.Length-1;i++) 
{
listBox1.Items.Add(ipp[i].ToString());
} to:客户端系统时间?    监听一下13号端口 :)accSock=sock.Accept();//用于接收客户端的连接请求,返回套接字对象
if(accSock.Connected)
{
IPAddress ipAddress=IPAddress.Parse(((IPEndPoint)accSock.RemoteEndPoint).Address.ToString());
IPAddress Port=IPAddress.Parse(((IPEndPoint)accSock.RemoteEndPoint).Port.ToString());
//获取客户端的IP地址

解决方案 »

  1.   

    TO:snof(雪狼) snof(雪狼) 
    我是想得到客户端的真实IP,你这代码好像不对头。
    我想知道,我怎么把上面用VBSCRIP写成C#的就行了。
      

  2.   

    using System.Collections.Specialized;
    NameValueCollection coll = Request.ServerVariables;
    string [] keys = coll.AllKeys;
    for(int i=0; i<keys.Length; i++)
    {
       string[] val=coll.GetValues(keys[i]);
         for (int j = 0; j < val.Length; j++) 
          {
          Response.Write(keys[i]+"="+ val[j] + "<br>");
          }
    }
    好像没有这个环境变量 HTTP_X_FORWARDED_FOR
    我也想知道,这个问题!!!
      

  3.   

    string ip=Request.ServerVariables.GetValues("REMOTE_ADDR")[0];
      

  4.   

    下面的示例将远程客户端的 IP 地址分配给一个字符串变量。
    [Visual Basic] 
    Dim ClientIP As String
     ClientIP = Request.UserHostAddress
    [C#] 
    String ClientIP;
     ClientIP = Request.UserHostAddress;