2030
2030
sent_total += sent
2031
2031
report_activity(sent, 'write')
2033
# socket.create_connection() is not available before python2.6, so we provide
2034
# it for earlier versions
2035
if getattr(socket, 'create_connection', None) is not None:
2036
connect_socket = socket.create_connection
2038
# We don't use nor handle the timeout though
2039
def connect_socket(address, timeout=None):
2040
err = socket.error('getaddrinfo returns an empty list')
2041
host, port = address
2042
for res in socket.getaddrinfo(host, port, 0, socket.SOCK_STREAM):
2043
af, socktype, proto, canonname, sa = res
2046
sock = socket.socket(af, socktype, proto)
2050
except exc_class, err:
2051
# 'err' is now the most recent error
2052
if sock is not None:
2054
raise exc_class, err
2034
def connect_socket(address, timeout=None):
2035
# Slight variation of the socket.create_connection() function (provided
2036
# by python-2.6) that can fail if getaddrinfo returns an empty list. We
2037
# also provide it for previous python versions. Also, we don't use the
2038
# timeout parameter so we don't implement it either.
2039
err = socket.error('getaddrinfo returns an empty list')
2040
host, port = address
2041
for res in socket.getaddrinfo(host, port, 0, socket.SOCK_STREAM):
2042
af, socktype, proto, canonname, sa = res
2045
sock = socket.socket(af, socktype, proto)
2049
except exc_class, err:
2050
# 'err' is now the most recent error
2051
if sock is not None:
2057
2056
def dereference_path(path):