473,769 Members | 6,583 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

resolving computer name by IP address

Hi!

i want to know if i have an ip address of a computer and its DNS server
name, if their is an windows API

that can resolve the computer name of the given ip address.

or vice verca - given a computer name and it's DNS server, i need to obtain
the IP address.

Thanks,
Uzi
Nov 15 '05 #1
1 18774
U can use gethostbyname, gethostbyaddr or same functions from WinSocket
library.
or use specific classes from .Net framework ..
like in this sample from msdn:

try
{
IPAddress hostIPAddress = IPAddress.Parse (IpAddressStrin g);
IPHostEntry hostInfo = Dns.GetHostByAd dress(hostIPAdd ress);
// Get the IP address list that resolves to the host names contained in
// the Alias property.
IPAddress[] address = hostInfo.Addres sList;
// Get the alias names of the addresses in the IP address list.
String[] alias = hostInfo.Aliase s;

Console.WriteLi ne("Host name : " + hostInfo.HostNa me);
Console.WriteLi ne("\nAliases :");
for(int index=0; index < alias.Length; index++) {
Console.WriteLi ne(alias[index]);
}
Console.WriteLi ne("\nIP address list : ");
for(int index=0; index < address.Length; index++) {
Console.WriteLi ne(address[index]);
}
}
catch(SocketExc eption e)
{
Console.WriteLi ne("SocketExcep tion caught!!!");
Console.WriteLi ne("Source : " + e.Source);
Console.WriteLi ne("Message : " + e.Message);
}
catch(FormatExc eption e)
{
Console.WriteLi ne("FormatExcep tion caught!!!");
Console.WriteLi ne("Source : " + e.Source);
Console.WriteLi ne("Message : " + e.Message);
}
catch(ArgumentN ullException e)
{
Console.WriteLi ne("ArgumentNul lException caught!!!");
Console.WriteLi ne("Source : " + e.Source);
Console.WriteLi ne("Message : " + e.Message);
}
catch(Exception e)
{
Console.WriteLi ne("Exception caught!!!");
Console.WriteLi ne("Source : " + e.Source);
Console.WriteLi ne("Message : " + e.Message);
}

"Uzi Baruch" <uz*******@hotm ail.com> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
Hi!

i want to know if i have an ip address of a computer and its DNS server
name, if their is an windows API

that can resolve the computer name of the given ip address.

or vice verca - given a computer name and it's DNS server, i need to obtain the IP address.

Thanks,
Uzi

Nov 15 '05 #2

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

Similar topics

1
369
by: Rushikesh Joshi | last post by:
Hi Friends I am having some query. On a server two site hosted 1) magnamags.com 2) stardustindia.com Now when I am resolving the IP address for this both sites. I am getting 202.71.136.211 (using GetHostByName).
0
1433
by: bk | last post by:
Request.ServerVariables("remote_addr") Request.ServerVariables("REMOTE_HOST") >-----Original Message----- >Hello, > >How can you get the computer name of a Cliënt computer, or the Ip address? >with aspx. >i need it to get the number of a table in a dinging room,
9
3944
by: Dan Nash | last post by:
Heylo I want to be able to get the computer name from my C# page. Is this possible? Basically, I'm developing a auto-bugreport feature for an intranet and want to know which machine sent the report. All machines are listed on the workgroup and in AD. Any suggestions? Cheers
0
4427
by: Ricky Chan | last post by:
I am using DNSQuery API to get computer name from IP address. However, by below sample code, I don't know how to specify the DNS Address for the field (ByVal aipServers As Integer). any idea? thank you very much ar! ------- <%@ Import Namespace="System.Runtime.InteropServices" %> <%@ Import Namespace="System.Net" %>
8
11376
by: Paul Bromley | last post by:
Thanks for your tolerance on this list. I asked the question regarding Commercial Copy Protection along with Unique PC Idnetifier and obtaining the active IP address. This was all to identify and tie down software to each PC on a network. I have just realised that the unique identity that I need to go for on the network and should be easy to get in a foolproof manner is the computer name. Hence which method will ALWAYS return the computer...
1
5530
by: kartik369 | last post by:
This code gets the IP address from the computer name we already know. I wanted to know how can we get the computer name if we know the IP address. Thanks void AsyncServer::InitSocks() { String* server = "CATUXPSD01"; int port = 4901; printf("in InitSocks"); String* request = String::Concat(S"Our test data asdf");
5
3733
by: Eng Teng | last post by:
What is the command to display computer name & ip address in VB.NET 2005 (OS WindowsXP & Windows Vista) Regards, Tee
0
1239
by: pawan tiwari | last post by:
please tell me the code for finding ip address of remote computer by its computer name
0
9424
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10223
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
10051
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...
0
8879
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...
1
7413
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5310
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...
0
5448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3571
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
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.