我希望能够从服务器端获取 IP地址。
TcpListener ftp_listener = new TcpListener(IPAddress.Any, ftpport);
newclient = listener.AcceptTcpClient();
请问如何查找新客户端的IP地址?
客户端方面
TcpClient ftpclient = new TcpClient();
ftpclient.Connect(ipAddress, ftpport);
如何查找 ftpclient 的 IP 地址?
目前我正在使用:
TcpClient ftpclient = new TcpClient();
//get IpAddress of Server
#pragma warning disable CS0618 // Type or member is obsolete
IPAddress ipAddress = Dns.Resolve("localhost").AddressList[0];
#pragma warning restore CS0618 // Type or member is obsolete
ftpclient.Connect(ipAddress, ftpport);// "192.168.1.160", ftpport);
请问有没有更好的方法将一个字符串转为整数?
谢谢。
newClient.Client.RemoteEndPoint.ToString()
。newClient.Client
提供了底层的套接字。 - Oguz Ozgul