def is_iana_reserved_port(port, protocol):
"""
Check whether the port is reserved by IANA
Args:
port (int): port
protocol (str): application protocol (tcp or udp)
Return:
bool: whether the port is reserved by IANA
"""
try:
socket.getservbyport(port, protocol)
return True
except socket.error:
return False
评论列表
文章目录