timeout in socket.gethostbyname()?

  • Thread starter Fortepianissimo
  • Start date
F

Fortepianissimo

I've tried using

socket.setdefaulttimeout(timeout)

to set the default timeout to 'timeout' for all sockets. The part
that's not clear to me, is that if this will affect
socket.gethostbyname(). In my observation the timeout setting did not
affect the DNS lookup.

It might be my misunderstanding of the semantics here: would
setdefaulttimeout() only applies to any socket object newly created?
So gethostbyname() doesn't create a new socket (explicitly at least)
so timeout doesn't apply there? What should I do to get the intended
behavior?

Thanks a bunch!
 
F

Fortepianissimo

Ok so for now I use a separate thread to run gethostbyname, and stop
waiting for the result if time is running up. But would be interested
in knowing a simpler way doing this. Thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,999
Messages
2,570,246
Members
46,842
Latest member
MableIwk73

Latest Threads

Top