kopia lustrzana https://github.com/micropython/micropython
17 wiersze
325 B
Python
17 wiersze
325 B
Python
import errno
|
|
import socket
|
|
|
|
|
|
def test(peer_addr):
|
|
s = socket.socket()
|
|
s.settimeout(1)
|
|
try:
|
|
s.connect(peer_addr)
|
|
except OSError as er:
|
|
print(er.errno == errno.ETIMEDOUT or str(er) == "timed out")
|
|
s.close()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
test(socket.getaddrinfo("192.0.0.0", 8888)[0][-1])
|