'Connects to a new socket, closing our previous one if we\'re already
attached.
:raises: :class:`stem.SocketError` if unable to make a socket'

def connect(self):

    with self._send_lock:
        if self.is_alive():
            self.close()
        with self._recv_lock:
            self._socket = self._make_socket()
            self._socket_file = self._socket.makefile(mode='rwb')
            self._is_alive = True
            self._connection_time = time.time()
            try:
                self._connect()
            except stem.SocketError:
                self._connect()
