def address_port(address):
'''
Return a string describing port portion of an address
If there is no port portion, returns None
'''
# Looks like an IPv4Address or IPv6Address
try:
# ignore type, it's always TCP
return "{}".format(address.port)
except AttributeError:
pass
# Looks like a HostnameAddress
# (we don't yet support hostnames in connect and listen)
try:
return "{}".format(address.port)
except AttributeError:
pass
# We don't know any other way to get a port
return None
评论列表
文章目录