'Connect to a server.
:param address: The server\'s address
:param port: The server\'s port
:param log_func: If provided, transfer stats will be passed to this
function during the transfer
:param timeout: Time duration to wait for connection to succeed
:raise FileTransferConnectError: Raised if the connection fails'

def __init__(self, address, port, log_func=None, timeout=20):

    self._socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    self._socket.settimeout(timeout)
    try:
        self._socket.connect((address, port))
    except socket.error as e:
        raise FileTransferConnectError(('Cannot    connect    to    server    at    %s:%s' % (address, port)), e)
    try:
        if (self._receive_msg(timeout) != RSS_MAGIC):
            raise FileTransferConnectError('Received    wrong    magic    number')
    except FileTransferTimeoutError:
        raise FileTransferConnectError('Timeout    expired    while    waiting    to    receive    magic    number')
    self._send(struct.pack('=i', CHUNKSIZE))
    self._log_func = log_func
    self._last_time = time.time()
    self._last_transferred = 0
    self.transferred = 0
