Re: System Ping (to resolve DNS)

new topic     » goto parent     » topic index » view thread      » older message » newer message

On 30 Jul 2002, at 18:35, Mark Moran wrote:

> 
> Hi folks
> 
> As part of an Internet client/server set of apps that I'm working on, 
> I'm including a function to resolve the domain name to the associated 
> IP.  (btw, I'm using win32lib and eulibnet includes at the moment.)
> 
> The way I've done it (certainly not the easiest, but it's the only way I 
> could easily figure to do it) is to call the system's PING command 
> (i.e., system("ping domain.com > pingresult.txt", i) - and can't 
> remember whether I'm using 1, 2, or 3 as "i", but doesn't matter).  
> 
> Then I open this pingresult.txt file for reading within my program, and 
> get the IP from the second line, which is between the "[" and "]".  Kind 
> of kludgy (sp?), but it works.
> 
> What I don't like, other than the obvious kludginess of the coding to do 
> all this, is that it opens a console window when it calls the system 
> command -- not very elegant when the rest of the program is a 
> nice-looking (IMHO) window.
> 
> >From the documentation, I 'think' system_exec() doesn't open a console, 
> but it also says that re-direction cannot be used.  I'd have to test it 
> of course, but...
> 
> Surely there's a more elegant way to do Internet resolution of domain 
> names.  Do any of you know something that'll work entirely within the 
> windows program (i.e., no additional console), and might be something as 
> simple as:
> 
> include dns.e
> sequence IPaddress
> dns_resolve(domain.com)
> IPaddress = whatIsReturnedFromdns_resolve
> 
> As mentioned, I'm using eulibnet, but I don't see anything in there that 
> might do it (although I haven't fully inspected eulibnet.ew) -- perhaps 
> there's something in tcp4u.ew?

No, but i have that on my to-do list also. Here is some possibly useful info:

look for "gethostbyaddr" in:
winsock.ew or ExWinsock.ew
ftp://ftp.stardust.com/pub/winsock/version1/docs/spec/winsock.html 
http://www.ibiblio.org/winsock/winsock-1.1/winsock.html

The call is in the tcp4w32.dll, so it is prolly accessable somewhere.


ICMP 37= Domain Name Request
ICMP 38= Domain Name Reply

CNAME
	The {canonical name} query type for {Domain Name System}.
	This query asks a DNS {server} for a {host}'s official
	{hostname}.
( it's case-insensitive )

see also:
RFC 1034
RFC 1035

I use the nameserver at 216.136.133.88.

Kat

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu