<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def connect():
 """ create socket and connect to adb server """

    global adb_socket
    if adb_socket is not None:
        raise RuntimeError('connection already existed')

    host, port = config.HOST, config.PORT

    connection = socket.socket()
    try:
        connection.connect((host, port))
    except ConnectionError as _:
        warn_msg = 'failed when connecting to adb server: {}:{}, retrying ...'.format(host, port)
        warnings.warn(warn_msg)
        reboot_adb_server()
        connect()
        return

    adb_socket = connection