def METHOD_NAME(sock, url, hostname, port, resource, **options):
    headers, key = _get_handshake_headers(resource, url, hostname, port, options)
    header_str = "\r\n".join(headers)
    send(sock, header_str)
    dump("request header", header_str)
    status, resp = _get_resp_headers(sock)
    if status in SUPPORTED_REDIRECT_STATUSES:
        return handshake_response(status, resp, None)
    success, subproto = _validate(resp, key, options.get("subprotocols"))
    if not success:
        raise WebSocketException("Invalid WebSocket Header")
    return handshake_response(status, resp, subproto)