개발/Python
Python 인터넷 연결 확인
LukeHan1128
2020. 11. 15. 17:12
반응형
#!/usr/bin/python3
import socket
def fnt_internet(self, host, port, timeout):
try:
socket.setdefaulttimeout(timeout)
socket.socket(socket.AF_INET, socket.SOCK_STREAM).connect((host, port))
return True
except Exception as ex:
print(ex)
return False
print(fnt_internet("8.8.8.8", 80, 3))
반응형