1. System Ping (to resolve DNS)

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?

Thanks in advance folks.

Mark.

new topic     » topic index » view message » categorize

2. Re: System Ping (to resolve DNS)

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 message » categorize

3. Re: System Ping (to resolve DNS)

Actually, if you go to http://pages.prodigy.net/mirwalds/ you will find
tcp.ew on the page. It includes heaps.e and structs.e (both by Chris
Bensler) to handle the memory operations, but it wraps the Async versions of
both gethostbyname() and gethostbyaddr().

 It does handle alot of the painfull stuff for Async lookups, and I believe
that the libs are all compatable with win32lib.

The zip file itself is here: http://pages.prodigy.net/mirwalds/tcp.zip

Jason

new topic     » goto parent     » topic index » view message » categorize

4. Re: System Ping (to resolve DNS)

Hi,

Probably best to do this via winsock, you could use one of the winsock
wrappers available but if all you need is the DNS resolve then have a
look at this bit of code I posted a while ago:

http://www.rat-software.com/misc.html

Thomas Parslow (PatRat)
E-Mail/Jabber: tom at almostobsolete.net
ICQ: 26359483

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu