Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

A Simple DNS Resolver

0.00/5 (No votes)
27 Mar 2004 1  
A simple DNS resolver compiled under Bloodshed C++ and using the Winsock 1.1 API

Sample Image - dns_resolver.jpg

Introduction

This is my first socks program. Actually, it's the first one I completed since I want to test it's fuctionality before adding it to my main project. It is a simple DNS resolver using the Winsock API (v1.1). The program is a console application that accepts hostname or IP address parameters which will be resolved using gethostbyname and/or gethostbyaddress functions.

I really had a hard time of looking for a DNS query code in the net using the winsock API so I decided to try and make one myself. I have actually tested the program and it works. Of course, you need an internet connection to query DNS outside your network, and if the IP/host you queried is dead or has no reverse DNS then it would just state a DNS lookup failed!

The source code has comments on it and is fairly understandable for intermediate and perhaps beginners in winsock programming. It is mainly focused on the hostent structure since I had a hard time implementing it before. It is compiled in Dev-C++ which you could download at http://www.bloodshed.net/ using its default libraries. I've also placed some comments on the source code for information on how to compile it.

Feel free to comment...

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