Hi friends,
I am trying to find out the IP address,ISP name (internet service provider) and Location of the FTP site.Now, i am in trouble with to find ip address for FTP site.
for example
System.Net.IPAddress[] sIPAddress = null;
sIPAddress= System.net.Dns.GetHostAddresses("ftp://www.c-sharpcorner.com");
it raise some error
" Cannot implicitly convert type 'System.Net.IPAddress[]' "
is there any possible solutions to find IP address for FTP sites and there is any way to find the ISP name and location for that IP address. any solutions could appreciated.
regards,
sasi
Loading
Zoran HorvatPosted Jul 27, 2011, 11:40 AM
string srv = null;
do
{
Console.Write("Enter server name: ");
srv = Console.ReadLine();
if (!string.IsNullOrEmpty(srv))
{
try
{
System.Net.IPAddress[] addr = System.Net.Dns.GetHostAddresses(srv);
for (int i = 0; i < addr.Length; i++)
Console.WriteLine("Name: {0}; Family: {1}; Address: {2}", srv, addr[i].AddressFamily, addr[i].ToString());
}
catch (System.Exception ex)
{
Console.WriteLine(ex.Message);
}
}
}
while (!string.IsNullOrEmpty(srv));
I've tried several addresses and results are interesting:
Name: www.microsoft.com; Family: InterNetwork; Address: 207.46.131.43
Name: ftp.microsoft.com; Family: InterNetwork; Address: 64.4.30.34
Name: ftp.c-sharpcorner.com; Family: InterNetwork; Address: 74.81.194.29
Name: www.c-sharpcorner.com; Family: InterNetwork; Address: 74.81.194.29
Name: www.sysexpand.com; Family: InterNetwork; Address: 66.96.146.89
Name: ftp.sysexpand.com; Family: InterNetwork; Address: 66.96.146.89
Name: www.oracle.com; Family: InterNetwork; Address: 46.33.68.118
Name: www.oracle.com; Family: InterNetwork; Address: 46.33.68.78
Name: ftp.oracle.com; Family: InterNetwork; Address: 141.146.44.21
You can see that large systems, like microsoft.com and oracle.com, hold FTP on different addresses. However, smaller sites, typically hosted for money at the ISP, have same address of FTP and HTTP server. That is typical situation on the Internet and it is directed by actual traffic made over FTP and HTTP.
Zoran
Zoran HorvatPosted Jul 27, 2011, 11:33 AM
for (int i = 0; i < addr.Length; i++)
Console.WriteLine("Family: {0}; Address: {1}", addr[i].AddressFamily, addr[i].ToString());
This code produces output:
Family: InterNetwork; Address: 66.96.146.89
This is read as IPv4 family address 66.96.146.89
Do not write protocol as part of the server name (ftp:// or http://) because that is not part of the server name - it only shows what protocol to use when communicating with the server.
Zoran