Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 18th, 2007, 03:26 AM
Registered User
 
Join Date: Feb 2007
Location: , , .
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

Reply With Quote
  #2 (permalink)  
Old March 19th, 2007, 06:32 AM
Registered User
 
Join Date: Mar 2007
Location: , , .
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 ;)

Reply With Quote
  #3 (permalink)  
Old March 19th, 2007, 07:50 AM
Registered User
 
Join Date: Feb 2007
Location: , , .
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??

Reply With Quote
  #4 (permalink)  
Old March 19th, 2007, 08:27 AM
Registered User
 
Join Date: Mar 2007
Location: , , .
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.

Reply With Quote
  #5 (permalink)  
Old March 19th, 2007, 11:05 AM
Registered User
 
Join Date: Feb 2007
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

done....thanks^_^

Reply With Quote
  #6 (permalink)  
Old March 21st, 2007, 10:29 PM
Registered User
 
Join Date: Mar 2007
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

It is a good method: Dns.GetHostEntry()

:)

Search Software
Reply With Quote
  #7 (permalink)  
Old June 18th, 2007, 10:41 AM
Registered User
 
Join Date: Jun 2007
Location: Karaj, Tehran, Iran.
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?


Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 05:21 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.