Click here to Skip to main content
Click here to Skip to main content

DNS if u need it

By , 1 Oct 2002
 

Introduction

Some times you want to receive information from DNS servers using C++. This simple project shows how you can send and receive messages to and from DNS servers.

There are 2 downloads supplied (see above)
The first download contains the DNS structures and CDnsResolver class that you can use to make queries of your own.
The second download contains a sample project, console application.
Use sample app:
usingdns.exe DNS server mail_host mail_host [any count hosts]

For advanced users I'm add new demo project dgramm.zip
This showing as interpret DNS answers (gethostbyname() too ;)

This cool for Mail servers or just for study how it works.

For more inforamtion read the RFC documentation at DNS.NET [^] which also contains a number of useful tools.

If you know how to return this information under plain Win32 please post a message below.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

DarkSn0w
Web Developer
Russian Federation Russian Federation
Member
Programmer with 5 year of work
like networking applications and fun codes

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
Generalgethostbyaddrmembermycia30 Mar '03 - 17:51 
nice work
I wonder if you could add more functions in it
especially the one that can do the same thing as gethostbyaddr()/WSAAsyncGetHostByAddr()/getnameinfo()
 
why I need that ?
1. gethostbyaddr() is not thread-safe
2. getnameinfo() is for win2k/xp only
3. WSAAsyncGetHostByAddr() is not designed for multi-thread use
4. it's easy to add the "Terminate" function in your code. gethostbyaddr() sometimes take many seconds to return the result, and no way to terminate while querying.
 
therefore, it would be much appreciated if you can add this new function
 
thank you
GeneralRe: gethostbyaddrmemberDarkSn0w22 Apr '03 - 3:34 
OK. this code is thread safe, what do you tell about Terminate function? where do you will user this?
In this code wery easy make terminate fuction, look at line witch WaitForSingleObject() function in query() function and you can make in this anything. Smile | :)
GeneralThanx...memberEPulse22 Feb '03 - 1:12 
Just what i needed...thanx for sharing your work. nevermind the english... most ppl here speak c++ instead... or they should..
GeneralRe: Thanx...memberDarkSn0w22 Apr '03 - 3:29 
thanks you. but i'm want make this more goodly. but i'm don't know as do it. this code is no 100% good. i'm must read full RFC, but i'm don't understant many words in this Frown | :( and my code not 100% compatible with RFC ;((
GeneralDNSQuery()memberAndreas Saurwein6 Feb '03 - 6:07 
Starting with Windows 2000, the Win32 API supports a function called DNSQuery() which does direct DNS queries for any record type. It even supports IPv6 type records.
Nice alternative if you are not depending on backwards compatibility.
 

... you keep forgetting that sheep shagging is not a crime in Australia ...Paul Watson, The Lounge
GeneralRe: DNSQuery()memberDarkSn0w22 Apr '03 - 3:26 
can you use this in win9x suxx? or wince?
GeneralDon't use this sourcememberwukas6 Feb '03 - 5:41 
I maked such mistake...
It so buggy, no more commentsMad | :mad:
GeneralRe: Don't use this sourcememberDarkSn0w22 Apr '03 - 3:25 
may be this has some mistakes and other things. but you may say about it, and i'm change this bugs. this code is only for education and i'm make for self study only Smile | :) .
GeneralRe: Don't use this sourcememberDarkSn0w6 Nov '03 - 19:37 
i'm know what this code has many errors..
but there was for testing of DNS quering and this belove that DNS answer has no any errors. If DNS answer is not corrent. this may fail. I have correct code for commercial application, but for beginners and this very good. Sorry for this errors. Smile | :)
GeneralRe: Don't use this sourcemember_BenC_22 Oct '04 - 1:35 
works well here! The article maybe a little terse but the code is good!
 
If people find something doesn't work for them - it helps if you can give a little information as to what the problem is - otherwise such comments are of little use to anyone!

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Permalink | Advertise | Privacy | Mobile
Web01 | 2.6.130523.1 | Last Updated 2 Oct 2002
Article Copyright 2002 by DarkSn0w
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid