473,770 Members | 1,953 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Obtaining hostname from IP Address

Hi,
I have an application where I monitor the status of a machine using it's IP
address. I would like to log an error when the machine goes down - but I want
to add the name of the machine along with the IP address in the log. Any
ideas how to achieve this? I have seen several examples of obtaining the IP
address given the host name using the dns.gethostbyna me function but have not
seen anything that will work the other way.

Thanks in advance.

Ajay Mirmira
Nov 21 '05 #1
2 2407
On 2005-02-09, amirmira <am******@discu ssions.microsof t.com> wrote:
Hi,
I have an application where I monitor the status of a machine using it's IP
address. I would like to log an error when the machine goes down - but I want
to add the name of the machine along with the IP address in the log. Any
ideas how to achieve this? I have seen several examples of obtaining the IP
address given the host name using the dns.gethostbyna me function but have not
seen anything that will work the other way.

Thanks in advance.

Ajay Mirmira


Dns.GetHostName () will get the name of the local machine.
--
Tom Shelton [MVP]
Nov 21 '05 #2
Tom,
I do not want the name of the local machine. I want the name of the remote
machine whose IP address I know. I used the function:

Dns.GetHostByAd dress("207.46.1 56.220").HostNa me

to get the host name. It works fine with machines on the internet(return s
"origin2.micros oft.com"), but for machines on the intranet, it does not
always work. It prefixes funny characters before the machine name. At first I
was under the impression that the DNS entries are somehow messed up - but I
double verified with the system admin (and also verified for myself) that
this is not the case.

Any ideas?

Thanks.

Ajay Mirmira

"Tom Shelton" wrote:
On 2005-02-09, amirmira <am******@discu ssions.microsof t.com> wrote:
Hi,
I have an application where I monitor the status of a machine using it's IP
address. I would like to log an error when the machine goes down - but I want
to add the name of the machine along with the IP address in the log. Any
ideas how to achieve this? I have seen several examples of obtaining the IP
address given the host name using the dns.gethostbyna me function but have not
seen anything that will work the other way.

Thanks in advance.

Ajay Mirmira


Dns.GetHostName () will get the name of the local machine.
--
Tom Shelton [MVP]

Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3128
by: Heinz | last post by:
Hi All I have a page where I trigger a command like xterm. <? $cmd="export DISPLAY=$disp ; xterm"; $out=shell_exec($cmd);
2
9830
by: Tim Veldhuizen | last post by:
Hi all! I'm attempting at writing a networked program. It is going to be a threaded irc server in c++ using almost nothing but oop code. And it needs to know the full hostname of the users that connect to it. I already get some info from this code: workersock = accept(mastersock, &sockaddr, &addrlen); printf("Received a Client Connection from: %s port: %d fd: %d\n", inet_ntoa(sockaddr.sin_addr), ntohs(sockaddr.sin_port), workersock);
2
5621
by: James M. | last post by:
I have 2x Front-end Web servers (Win2003 Ent IIS6.0), setup with NLB (single Affinity, also using SQLServer session state) that are hosting a few .NET ASP web applications under the Default Website in IIS, and accessing via a Intranet LAN (this is not publicly available). NETWEB1: NIC1 172.16.17.220 172.16.17.244 (NLB Virtual IP) NIC2 172.16.17.221
7
21316
by: Privacy Advocate | last post by:
//crossposted to: comp.lang.javascript, alt.comp.lang.javascript in an effort to get factual answers from JavaScript experts// Simply put; Is it possible to obtain the real (actual) IP address of someone (client) that visits a web site through an anonymous proxy if this person ONLY has JavaScript enabled in their browser? This is NOT a question about PHP, perl, VBScript, Java(.class), or ActiveX. Let us _only_ deal with JavaScript for...
3
4792
by: Microlong® | last post by:
Currently, I want to get the IP address from giving hostname in the Active Server Page. I know the hostname, I want to get the IP address via hostname in an ASP page. -- Developer QA Dashboard Microsoft China Development Centre
3
3791
by: HiChetu | last post by:
I have a host which has two NIC cards; one configured for LAN connections, and another for external connections. Say the ip address are 1) x.x.x.x - for LAN 2) y.y.y.y - for external hostname = 'hichetu' With the following code snippet...
0
1525
by: James M via .NET 247 | last post by:
(I have 2x Front-end Web servers (Win2003 Ent IIS6.0), setup withNLB (single Affinity, also using SQLServer session state) thatare hosting a few .NET ASP web applications under the DefaultWebsite in IIS, and accessing via a Intranet LAN (this is notpublicly available). NETWEB1: NIC1 172.16.17.220 172.16.17.244 (NLB Virtual IP) NIC2 172.16.17.221 NETWEB2:
11
2509
by: seannakasone | last post by:
Is there a way to get the callstack level in c++? for example, take the following code: void call3() { //callstack level would be 3 } void call2() { //callstack level would be 2 call3();
3
7225
by: Mark Delaney | last post by:
When using the MS SQL 2005 JDBC driver, I now need to have the DNS name resolution to the client correctly set up. If not I get the following error: SQLState: 08S01 SQLError: 0 Message: hostname : hostname Where "hostname" is the client host name. It doesn't seem to matter if I
0
9617
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10254
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10099
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10036
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8929
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5354
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4007
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3607
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2849
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.