The connection of python to some ip

Campus network needs to be authenticated. If not,

s = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
s.settimeout(3)
s.connect(("ip",80))
s.close()

also works properly.
ask how to test whether the network of the specified ip is working.

Jul.06,2021

s.connect (('some ip',80)) if there is an error in the connection, it will return the error of socket.error. Can you judge by this error?


something like this

try:
    if protocol.upper() == 'UDP':
        sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    else:
        sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

    if port == 443:
        sock = ssl.wrap_socket(sock, ssl_version=ssl.PROTOCOL_SSLv23)

    sock.settimeout(2)
    sock.connect((address, port))
    return True
except socket.error as e:
    return False
except Exception as e:
    return False
finally:
    sock.close()

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3ef00-2c47f.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3ef00-2c47f.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?