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

  • Home
  • SEARCH
  • 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 8638525
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T10:45:04+00:00 2026-06-12T10:45:04+00:00

I need to write a paper on how DNS works and build a small

  • 0

I need to write a paper on how DNS works and build a small but functional DNS server in python.

I have a simple UDP socket server that opens a thread when a packet is received like this:

while 1:
  try:
    stream, addr = serversocket.recvfrom(buffr)
    threading.Thread(target=handler, args=(stream, addr, threading.activeCount(),)).start()
  except:
    exc_type, exc_value, exc_traceback = sys.exc_info()
    except_catch(exc_type.__name__, exc_value, exc_traceback, threading.current_thread().name)

The handler function simply tries to find the record requested in memory and if it does not it will execute another function that runs a dns query on another server to fetch the record if he does not have it. This is somewhat of a fail-safe and where my problem is.

def dnsrn(ip, type):
  try:
    mkr = dns.resolver.Resolver()
    mkr.nameservers = ['192.168.0.1']
    res = mkr.query(ip, type)

    for rdata in res:
      return rdata.address # this works for A records
      # to do for other types of records

  except:
    exc_type, exc_value, exc_traceback = sys.exc_info()
    except_catch(exc_type.__name__, exc_value, exc_traceback, threading.current_thread().name)

I have not yet finished it as you can see but I already have a problem.
Sometimes, this function will hand and the thread will never finish without it giving any error what so ever in the error log.
I have tested and the error log should capture all errors thrown by the child.
I have a simple client that is programmed to send a random request out a lit of presets every set time and there seems to be no pattern to when the child hangs.
After about 24 hours of testing I’m left with about 1-3 zombie threads.

In case you are wondering this is what the exception function looks like:

def except_catch(type, value, track, thread=None):
  if type != "SystemExit":
    import traceback

    rawreport = traceback.format_exception(type, value, track)
    report = "\n" . join(rawreport)

    errorlog = open(error_log_path + "/errors.log", "a")

    if thread != None:
      errorlog.write("Exception in thread: " + thread + "\n\n")

    errorlog.write(("%s\n" + "-" * 30 + "\n\n") % report)

    errorlog.close()
sys.excepthook = except_catch
  • 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-06-12T10:45:05+00:00Added an answer on June 12, 2026 at 10:45 am

    I would check the RFC as this is the exact specification of the protocol. The problem with DNS is, that there is more than one RFC. For a simple start, I would check RFC 1035 which contains the basics. If you need advanced functionality, check the other related RFCs.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to write some input data files for a python program, and I
I need to write to a text file using JavaScript. I have a machine
I need to write the output of the code I have to a file
I am trying to write a short paper with LaTeX and need to add
I need to write a paper about a web crawler and this web crawler
Have a problem that seems easy on paper but i'm having a big problem
The application need write file's last modification date. void Dater(String DateFile) { File file
I need to write a script in Matlab, which will read some data from
I need to write a C++ code coverage program that takes in another C++
I need to write a query where I need to find the ' character.

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.