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.
|
Not Categorized, Please Help
|
|