Click here to Skip to main content
12,954,276 members (73,818 online)
Click here to Skip to main content
Add your own
alternative version

Stats

98.2K views
6.1K downloads
31 bookmarked
Posted 27 Mar 2004

A Simple DNS Resolver

, 27 Mar 2004 CPOL
Rate this:
Please Sign up or sign in to vote.
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, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

JLèé
Philippines Philippines
No Biography provided

You may also be interested in...

Comments and Discussions

 
GeneralBUILD problem Pin
motz14313-Oct-09 7:01
membermotz14313-Oct-09 7:01 
GeneralSlow if the host doesn't exist Pin
Ludvik Jerabek23-Jan-08 15:27
memberLudvik Jerabek23-Jan-08 15:27 
GeneralRe: Slow if the host doesn't exist Pin
JLèé23-Jan-08 23:21
memberJLèé23-Jan-08 23:21 
QuestionProblem in Building.... Pin
charlesra20522-Aug-06 4:02
membercharlesra20522-Aug-06 4:02 
AnswerRe: Problem in Building.... Pin
JLèé22-Aug-06 10:48
memberJLèé22-Aug-06 10:48 
Generalcompile Pin
Dave_Nunes24-Jan-06 10:08
memberDave_Nunes24-Jan-06 10:08 
GeneralCongratulations Pin
Tommahawk12-Jan-05 17:15
memberTommahawk12-Jan-05 17:15 
GeneralRe: Congratulations Pin
JLèé12-Jan-05 20:59
memberJLèé12-Jan-05 20:59 
GeneralQueries Pin
AslFunky2-Jan-05 7:37
memberAslFunky2-Jan-05 7:37 
GeneralRe: Queries Pin
JLèé12-Jan-05 22:05
memberJLèé12-Jan-05 22:05 
GeneralRe: Queries Pin
AslFunky15-Jan-05 8:01
memberAslFunky15-Jan-05 8:01 
GeneralRe: Queries Pin
EastMohican14-Jul-05 15:20
memberEastMohican14-Jul-05 15:20 
<< There is no need to get mx records on a domain since the SMTP server of the domain will search the mx records for you >>
What the SMTP server has to do with the MX lookup request?? The SMTP server of the receiving domain just expects a connection from outside from a given port (usually 25). If you intend to send a mail to yahoo.com, 3 cases:
- either you prepare a mail and provide it to "sendmail" for instance which does all the work
- or you use one of the API on your computer to send the mail (eg MAPI), and this API will resolve the MX entries and actually establish connection to one of the results (send mail)
- or, and I think this is the case here, you write your own API and bypass your local mail sender subsystem (eg MAPI) to send the mail, in this case you have to resolve the MX entries yourself then connect to one of the answers from the NS.

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

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170525.1 | Last Updated 28 Mar 2004
Article Copyright 2004 by JLèé
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid