Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 18th, 2007, 03:26 AM
Registered User
 
Join Date: Feb 2007
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default how to get hostname from ip address?

could you please give me an example?
thanks

 
Old March 19th, 2007, 06:32 AM
Registered User
 
Join Date: Mar 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Perhaps you should take a look at Dns.GetHostByAddress(), it takes a string (ip address) as a parameter and returns a IPHostEntry, from which you can get the host at the HostName property:

string host = Dns.GetHostByAddress("192.168.0.15").HostName;

P.S. I didn't test this, just browsed the documentation ;)

 
Old March 19th, 2007, 07:50 AM
Registered User
 
Join Date: Feb 2007
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanks a lot for your attention..
it works..but this method in framkwork 2.0 is out of date
is there any new methods??

 
Old March 19th, 2007, 08:27 AM
Registered User
 
Join Date: Mar 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Oh yes, sorry about that.
.NET 2.0 have the Dns.GetHostEntry() method that should do the same.

 
Old March 19th, 2007, 11:05 AM
Registered User
 
Join Date: Feb 2007
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

done....thanks^_^

 
Old March 21st, 2007, 10:29 PM
Registered User
 
Join Date: Mar 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

It is a good method: Dns.GetHostEntry()

:)

Search Software
 
Old June 18th, 2007, 10:41 AM
Registered User
 
Join Date: Jun 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The Method is interesting but it didn't work for me in this case
when I get the HostName it gives me the IP Address Again!!

i used winSock APIs instead and it just worked

anybody has an idea about this?







Similar Threads
Thread Thread Starter Forum Replies Last Post
IP Address sumanghosh Classic ASP Basics 1 April 7th, 2006 11:24 AM
get hostname from IP cygnusx04 Classic ASP Basics 12 October 14th, 2004 02:19 PM
Retreiving IP address & gateway address sjangit VBScript 0 February 3rd, 2004 02:02 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.