def patch_socket():
""" Bind inet_ntop and inet_pton function to socket module.
socket.inet_pton and socket.inet_ntop are available only on most Unix platforms.
Here we use custom function if there are no inet_pton or inet_ntop defined.
Ref: https://docs.python.org/2/library/socket.html#socket.inet_pton
"""
if not hasattr(socket, 'inet_pton'):
socket.inet_pton = inet_pton
if not hasattr(socket, 'inet_ntop'):
socket.inet_ntop = inet_ntop
评论列表
文章目录