Python Sockets Help

Mark M Manning mark.manning at
Mon Mar 10 23:58:03 CET 2008

I need your expertise with a sockets question.

Let me preface this by saying I don't have much experience with
sockets in general so this question may be simple.

I am playing with the mini dns server from a script I found online:

All I want to do is edit this script so that it records the IP
address.  I've seen other examples use the accept() object which
returns the data and the IP address it is receiving the data from.  I
can't use that in this case but I'm wondering if someone could show me

Here is the socket part of the script:

if __name__ == '__main__':
  print 'pyminifakeDNS:: dom.query. 60 IN A %s' % ip

  udps = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)

    while 1:
      data, addr = udps.recvfrom(1024)
      udps.sendto(p.respuesta(ip), addr)
      print 'Respuesta: %s -> %s' % (p.dominio, ip)
  except KeyboardInterrupt:
    print 'Finalizando'

Thanks to everyone in advance!

More information about the Python-list mailing list