dont set global socket timeout

This commit is contained in:
j 2015-12-24 17:58:11 +05:30
commit 96a3cdb4b2
2 changed files with 4 additions and 2 deletions

View file

@ -353,8 +353,9 @@ def can_connect_dns(host="8.8.8.8", port=53):
port: 53/tcp
"""
try:
socket.setdefaulttimeout(1)
socket.socket(socket.AF_INET, socket.SOCK_STREAM).connect((host, port))
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.settimeout(1)
s.connect((host, port))
return True
except:
pass