DWK:
私が取得したいたIPAddressからの
サーバ側
TcpListener ftp_listener = new TcpListener(IPAddress.Any, ftpport);
newclient = listener.AcceptTcpClient();
どのように私は見つけるのですかNEWCLIENT ipaddressにしてください
クライアント側
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);
より良い方法はあります...
感謝
OGUZ Ozgul:
サーバーとクライアントの両方のために、リモートエンドポイント(IPアドレスとポート)を取得するためのアプローチは同じです。
サーバー上のクライアントのIPアドレスを取得します。
IPEndPoint remoteIpEndPoint = newclient.Client.RemoteEndPoint as IPEndPoint; Console.WriteLine("Client IP Address is: {0}", remoteIpEndPoint.Address);
クライアント上のサーバーのIPアドレスを取得します。
IPEndPoint remoteIpEndPoint = ftpclient.Client.RemoteEndPoint as IPEndPoint; Console.WriteLine("FTP Server IP Address is: {0}", remoteIpEndPoint.Address);