Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3240274
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T18:04:00+00:00 2026-05-17T18:04:00+00:00

I just want to write DNS client program using C sockets that takes three

  • 0

I just want to write DNS client program using C sockets that
takes three arguments: a query name (e.g., host name or domain name) and a query type (A, or NS, or MX), and DNS server name. Print out the responses in the answer section of the DNS record received.

I know there is a command getaddrinfo..
but I just want to connect to lookup table and then
get the DNS server name…

so when i give the input ./a.out http://www.google.com A 144.20.190.70

it will show something similar to this:

Server: 144.20.190.70
Address: 144.20.190.70#53

Non-authoritative answer:

Name : http://www.google.com

Canonical name : http://www.l.google.com

Name : http://www.l.google.com
Address : 74.125.19.104

Name : http://www.l.google.com
Address : 74.125.19.105

Name : http://www.l.google.com
Address : 74.125.19.106

Name : http://www.l.google.com
Address : 74.125.19.147

Name : http://www.l.google.com
Address : 74.125.19.99

Name : http://www.l.google.com
Address : 74.125.19.103

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T18:04:00+00:00Added an answer on May 17, 2026 at 6:04 pm

    Yes you need to see Bev.net.dns class that Rob-philpott made for .net

    Click Here

    building requests to send to DNS servers is not easy but once you can get the answer back from the server then you need to send it back to the browser and this is the bit i’ve got stuck on.

    i listen on port 53/UDP and get the request and send it to the DNS server and get a valid responce but then i send that back to the browser using the remote client port as a UDP but the browser will not except the reply.

    Robs code is real easy to use as shown below “Resolver.Lookup” and i just neded to add a bit so that the original byte array sent from the DNS server as saved in Resolver.Message ready to send back to the browser.

        public void Listen()
        {
            receiveSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp );
            receiveEndPoint = new IPEndPoint(IPAddress.Any, receivePort); receiveSocket.Bind(receiveEndPoint); 
            receivePort = (receiveSocket.LocalEndPoint as IPEndPoint).Port; 
            receiveBuffer = new byte[BufferSize]; 
            receiveAsyncResult = receiveSocket.BeginReceiveFrom(receiveBuffer, 0, receiveBuffer.Length, SocketFlags.None, ref receiveEndPoint, new AsyncCallback(NetworkMessageReceivedCallback), receiveSocket);
        }
    
    
        public void NetworkMessageReceivedCallback(IAsyncResult asyncResult)
        {
            EndPoint remoteEndPoint = null;            
            byte[] bytes = null;                        
            remoteEndPoint = new IPEndPoint(IPAddress.Any, 0); //Will contain the clients port                
            int bytesRead = receiveSocket.EndReceiveFrom(asyncResult, ref remoteEndPoint);                                              
            bytes = new Byte[bytesRead];                
            Buffer.BlockCopy(receiveBuffer, 0, bytes, 0, bytesRead);
           //string ip = "208.67.222.222";
           string ip = "192.168.1.254";
           IPAddress dnsServer = IPAddress.Parse(ip);
           Response R = Resolver.Lookup(bytes, dnsServer);
           receiveSocket.SendTo(R.Message , remoteEndPoint);//127.0.0.1
           receiveSocket.Close();
       Listen();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just want a simple tool that will help me quickly write scripts/packages that
I want to write something that acts just like confirm() in javascript, but I
Just want to know if there other optional wrapper framework available that generate client
I just want a quick way (and preferably not using a while loop)of createing
I just want my apache to register some of my predefined environment so that
I just want to add a couple subdomains to my computers FQDN so that
I have a div that I want to write to a popup window (for
I am trying to write my first WCF Service. Right now I just want
I just want an ASP.NET DropDownList with no selected item. Setting SelectedIndex to -1
I just want to see what files were modded/added/deleted between 2 arbitrary revisions. How

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.