code-dumps/py/socket-test.py

13 lines
303 B
Python
Executable File

#!/usr/bin/python3
import socket
import traceback
try:
print(socket.gethostbyname('rrtest.zoo.lo'))
client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
client_socket.settimeout(3)
client_socket.connect(('rrtest.zoo.lo', 5000))
except socket.error as e:
print('Cannot connect', e)