code: def connect(self):
          '''Establish a connection.'''
          _logger.debug(__('Connecting to {0}.', self._address))
  
          if self._state != ConnectionState.ready:
              raise Exception('Closed connection must be reset before reusing.')
  
          if self._sock:
              connection_future = asyncio.open_connection(
                  sock=self._sock, **self._connection_kwargs()
              )
          else:
              # TODO: maybe we don't want to ignore flow-info and scope-id?
              host = self._address[0]
              port = self._address[1]
  
              connection_future = asyncio.open_connection(
                  host, port, **self._connection_kwargs()
              )
  
          self.reader, self.writer = yield from \
              self.run_network_operation(
                  connection_future,
                  wait_timeout=self._connect_timeout,
                  name='Connect')
  
          if self._timeout is not None:
              self._close_timer = CloseTimer(self._timeout, self)
          else:
              self._close_timer = DummyCloseTimer()
  
          self._state = ConnectionState.created
          _logger.debug('Connected.'f connect(self):
          '''Establish a connection.'''
          _logger.debug(__('Connecting to {0}.', self._address))
  
          if self._state != ConnectionState.ready:
              raise Exception('Closed connection must be reset before reusing.')
  
          if self._sock:
              connection_future = asyncio.open_connection(
                  sock=self._sock, **self._connection_kwargs()
              )
          else:
              # TODO: maybe we don't want to ignore flow-info and scope-id?
              host = self._address[0]
              port = self._address[1]
  
              connection_future = asyncio.open_connection(
                  host, port, **self._connection_kwargs()
              )
  
          self.reader, self.writer = yield from \
              self.run_network_operation(
                  connection_future,
                  wait_timeout=self._connect_timeout,
                  name='Connect')
  
          if self._timeout is not None:
              self._close_timer = CloseTimer(self._timeout, self)
          else:
              self._close_timer = DummyCloseTimer()
  
          self._state = ConnectionState.created
          _logger.debug('Connected.')
docs: Establish a connection.