• Home
  • Raw
  • Download

Lines Matching +full:srv +full:- +full:ipv4 +full:- +full:simple +full:- +full:service +full:- +full:config

1 /*  GIO - GLib Input, Output and Streaming Library
24 #include "config.h"
57 #include "gmarshal-internal.h"
66 * @short_description: Helper for connecting to a network service
70 * #GSocketClient is a lightweight high-level utility class for connecting to
134 family = client->priv->family; in G_DEFINE_TYPE_WITH_PRIVATE()
136 client->priv->local_address != NULL) in G_DEFINE_TYPE_WITH_PRIVATE()
137 family = g_socket_address_get_family (client->priv->local_address); in G_DEFINE_TYPE_WITH_PRIVATE()
142 client->priv->type, in G_DEFINE_TYPE_WITH_PRIVATE()
143 client->priv->protocol, in G_DEFINE_TYPE_WITH_PRIVATE()
148 if (client->priv->local_address) in G_DEFINE_TYPE_WITH_PRIVATE()
155 client->priv->local_address, in G_DEFINE_TYPE_WITH_PRIVATE()
164 if (client->priv->timeout) in G_DEFINE_TYPE_WITH_PRIVATE()
165 g_socket_set_timeout (socket, client->priv->timeout); in G_DEFINE_TYPE_WITH_PRIVATE()
173 GSocketClientPrivate *priv = client->priv; in can_use_proxy()
175 return priv->enable_proxy in can_use_proxy()
176 && priv->type == G_SOCKET_TYPE_STREAM; in can_use_proxy()
216 client->priv = g_socket_client_get_instance_private (client); in g_socket_client_init()
217 client->priv->type = G_SOCKET_TYPE_STREAM; in g_socket_client_init()
218 client->priv->app_proxies = g_hash_table_new_full (g_str_hash, in g_socket_client_init()
245 g_clear_object (&client->priv->local_address); in g_socket_client_finalize()
246 g_clear_object (&client->priv->proxy_resolver); in g_socket_client_finalize()
248 G_OBJECT_CLASS (g_socket_client_parent_class)->finalize (object); in g_socket_client_finalize()
250 g_hash_table_unref (client->priv->app_proxies); in g_socket_client_finalize()
264 g_value_set_enum (value, client->priv->family); in g_socket_client_get_property()
268 g_value_set_enum (value, client->priv->type); in g_socket_client_get_property()
272 g_value_set_enum (value, client->priv->protocol); in g_socket_client_get_property()
276 g_value_set_object (value, client->priv->local_address); in g_socket_client_get_property()
280 g_value_set_uint (value, client->priv->timeout); in g_socket_client_get_property()
284 g_value_set_boolean (value, client->priv->enable_proxy); in g_socket_client_get_property()
370 return client->priv->family; in g_socket_client_get_family()
384 * connection to be an ipv4 socket, even though the address might
385 * be an ipv6 mapped to ipv4 address.
393 if (client->priv->family == family) in g_socket_client_set_family()
396 client->priv->family = family; in g_socket_client_set_family()
415 return client->priv->type; in g_socket_client_get_socket_type()
436 if (client->priv->type == type) in g_socket_client_set_socket_type()
439 client->priv->type = type; in g_socket_client_set_socket_type()
458 return client->priv->protocol; in g_socket_client_get_protocol()
479 if (client->priv->protocol == protocol) in g_socket_client_set_protocol()
482 client->priv->protocol = protocol; in g_socket_client_set_protocol()
501 return client->priv->local_address; in g_socket_client_get_local_address()
526 if (client->priv->local_address) in g_socket_client_set_local_address()
528 g_object_unref (client->priv->local_address); in g_socket_client_set_local_address()
530 client->priv->local_address = address; in g_socket_client_set_local_address()
531 g_object_notify (G_OBJECT (client), "local-address"); in g_socket_client_set_local_address()
549 return client->priv->timeout; in g_socket_client_get_timeout()
571 if (client->priv->timeout == timeout) in g_socket_client_set_timeout()
574 client->priv->timeout = timeout; in g_socket_client_set_timeout()
591 return client->priv->enable_proxy; in g_socket_client_get_enable_proxy()
613 if (client->priv->enable_proxy == enable) in g_socket_client_set_enable_proxy()
616 client->priv->enable_proxy = enable; in g_socket_client_set_enable_proxy()
617 g_object_notify (G_OBJECT (client), "enable-proxy"); in g_socket_client_set_enable_proxy()
634 return client->priv->tls; in g_socket_client_get_tls()
654 * setting a client-side certificate to use, or connecting to the
655 * #GTlsConnection::accept-certificate signal), you can connect to
668 if (tls == client->priv->tls) in g_socket_client_set_tls()
671 client->priv->tls = tls; in g_socket_client_set_tls()
689 return client->priv->tls_validation_flags; in g_socket_client_get_tls_validation_flags()
706 if (client->priv->tls_validation_flags != flags) in g_socket_client_set_tls_validation_flags()
708 client->priv->tls_validation_flags = flags; in g_socket_client_set_tls_validation_flags()
709 g_object_notify (G_OBJECT (client), "tls-validation-flags"); in g_socket_client_set_tls_validation_flags()
729 if (client->priv->proxy_resolver) in g_socket_client_get_proxy_resolver()
730 return client->priv->proxy_resolver; in g_socket_client_get_proxy_resolver()
746 * depends on the setting of #GSocketClient:enable-proxy, which is not
762 if (client->priv->proxy_resolver) in g_socket_client_set_proxy_resolver()
763 g_object_unref (client->priv->proxy_resolver); in g_socket_client_set_proxy_resolver()
765 client->priv->proxy_resolver = proxy_resolver; in g_socket_client_set_proxy_resolver()
767 if (client->priv->proxy_resolver) in g_socket_client_set_proxy_resolver()
768 g_object_ref (client->priv->proxy_resolver); in g_socket_client_set_proxy_resolver()
776 gobject_class->finalize = g_socket_client_finalize; in g_socket_client_class_init()
777 gobject_class->set_property = g_socket_client_set_property; in g_socket_client_class_init()
778 gobject_class->get_property = g_socket_client_get_property; in g_socket_client_class_init()
792 * - %G_SOCKET_CLIENT_RESOLVING: @client is about to look up @connectable in g_socket_client_class_init()
795 * - %G_SOCKET_CLIENT_RESOLVED: @client has successfully resolved in g_socket_client_class_init()
798 * - %G_SOCKET_CLIENT_CONNECTING: @client is about to make a connection in g_socket_client_class_init()
804 * - %G_SOCKET_CLIENT_CONNECTED: @client has successfully connected in g_socket_client_class_init()
807 * - %G_SOCKET_CLIENT_PROXY_NEGOTIATING: @client is about to negotiate in g_socket_client_class_init()
811 * - %G_SOCKET_CLIENT_PROXY_NEGOTIATED: @client has negotiated a in g_socket_client_class_init()
816 * - %G_SOCKET_CLIENT_TLS_HANDSHAKING: @client is about to begin a TLS in g_socket_client_class_init()
819 * - %G_SOCKET_CLIENT_TLS_HANDSHAKED: @client has successfully completed in g_socket_client_class_init()
822 * - %G_SOCKET_CLIENT_COMPLETE: @client has either successfully connected in g_socket_client_class_init()
885 g_param_spec_object ("local-address", in g_socket_client_class_init()
903 g_param_spec_boolean ("enable-proxy", in g_socket_client_class_init()
920 g_param_spec_flags ("tls-validation-flags", in g_socket_client_class_init()
930 * GSocketClient:proxy-resolver: in g_socket_client_class_init()
937 g_param_spec_object ("proxy-resolver", in g_socket_client_class_init()
958 * DNS returns an IPv4 and IPv6 address. First we'll connect() to the
959 * IPv4 address, and say that succeeds, but TLS is enabled and the TLS
988 g_assert (info->tmp_error == NULL); in socket_client_error_info_free()
989 g_clear_error (&info->best_error); in socket_client_error_info_free()
997 if (info->tmp_error == NULL) in consider_tmp_error()
1009 if (event >= info->best_error_event) in consider_tmp_error()
1011 g_clear_error (&info->best_error); in consider_tmp_error()
1012 info->best_error = info->tmp_error; in consider_tmp_error()
1013 info->tmp_error = NULL; in consider_tmp_error()
1014 info->best_error_event = event; in consider_tmp_error()
1018 g_clear_error (&info->tmp_error); in consider_tmp_error()
1068 if (client->priv->proxy_resolver && in g_socket_client_connect()
1072 "proxy-resolver", client->priv->proxy_resolver, in g_socket_client_connect()
1088 g_clear_error (&error_info->best_error); in g_socket_client_connect()
1089 g_cancellable_set_error_if_cancelled (cancellable, &error_info->best_error); in g_socket_client_connect()
1099 &error_info->tmp_error); in g_socket_client_connect()
1111 g_assert (&error_info->best_error != NULL); in g_socket_client_connect()
1116 client->priv->enable_proxy); in g_socket_client_connect()
1118 socket = create_socket (client, address, &error_info->tmp_error); in g_socket_client_connect()
1131 address, cancellable, &error_info->tmp_error)) in g_socket_client_connect()
1138 clarify_connect_error (error_info->tmp_error, connectable, address); in g_socket_client_connect()
1157 g_critical ("Trying to proxy over non-TCP connection, this is " in g_socket_client_connect()
1160 g_set_error_literal (&error_info->tmp_error, in g_socket_client_connect()
1162 _("Proxying over a non-TCP connection is not supported.")); in g_socket_client_connect()
1168 else if (g_hash_table_contains (client->priv->app_proxies, protocol)) in g_socket_client_connect()
1181 &error_info->tmp_error); in g_socket_client_connect()
1193 g_set_error (&error_info->tmp_error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED, in g_socket_client_connect()
1202 if (!application_proxy && connection && client->priv->tls) in g_socket_client_connect()
1206 tlsconn = g_tls_client_connection_new (connection, connectable, &error_info->tmp_error); in g_socket_client_connect()
1213 client->priv->tls_validation_flags); in g_socket_client_connect()
1216 cancellable, &error_info->tmp_error)) in g_socket_client_connect()
1248 g_propagate_error (error, g_steal_pointer (&error_info->best_error)); in g_socket_client_connect()
1268 * address, an IPv4 address, or a domain name (in which case a DNS
1290 * In the event of any failure (DNS error, service not found, no hosts
1291 * connectable) %NULL is returned and @error (if non-%NULL) is set
1323 * @service: the name of the service to connect to
1327 * Attempts to create a TCP connection to a service.
1329 * This call looks up the SRV record for @service at @domain for the
1331 * the hosts providing the service until either a connection succeeds
1338 * In the event of any failure (DNS error, service not found, no hosts
1339 * connectable) %NULL is returned and @error (if non-%NULL) is set
1347 const gchar *service, in g_socket_client_connect_to_service() argument
1354 connectable = g_network_service_new (service, "tcp", domain); in g_socket_client_connect_to_service()
1382 * determine when to use application-specific proxy protocols.
1388 * In the event of any failure (DNS error, service not found, no hosts
1389 * connectable) %NULL is returned and @error (if non-%NULL) is set
1441 data->task = NULL; in g_socket_client_async_connect_data_free()
1442 g_clear_object (&data->connectable); in g_socket_client_async_connect_data_free()
1443 g_clear_object (&data->enumerator); in g_socket_client_async_connect_data_free()
1444 g_clear_object (&data->enumeration_cancellable); in g_socket_client_async_connect_data_free()
1445 g_slist_free_full (data->connection_attempts, connection_attempt_unref); in g_socket_client_async_connect_data_free()
1446 g_slist_free_full (data->successful_connections, connection_attempt_unref); in g_socket_client_async_connect_data_free()
1448 g_clear_pointer (&data->error_info, socket_client_error_info_free); in g_socket_client_async_connect_data_free()
1469 g_ref_count_init (&attempt->ref); in connection_attempt_new()
1476 g_ref_count_inc (&attempt->ref); in connection_attempt_ref()
1484 if (g_ref_count_dec (&attempt->ref)) in connection_attempt_unref()
1486 g_clear_object (&attempt->address); in connection_attempt_unref()
1487 g_clear_object (&attempt->socket); in connection_attempt_unref()
1488 g_clear_object (&attempt->connection); in connection_attempt_unref()
1489 g_clear_object (&attempt->cancellable); in connection_attempt_unref()
1490 g_clear_object (&attempt->proxy_addr); in connection_attempt_unref()
1491 if (attempt->timeout_source) in connection_attempt_unref()
1493 g_source_destroy (attempt->timeout_source); in connection_attempt_unref()
1494 g_source_unref (attempt->timeout_source); in connection_attempt_unref()
1503 attempt->data->connection_attempts = g_slist_remove (attempt->data->connection_attempts, attempt); in connection_attempt_remove()
1512 for (l = data->connection_attempts; l; l = g_slist_next (l)) in cancel_all_attempts()
1514 ConnectionAttempt *attempt_entry = l->data; in cancel_all_attempts()
1515 g_cancellable_cancel (attempt_entry->cancellable); in cancel_all_attempts()
1518 g_slist_free (data->connection_attempts); in cancel_all_attempts()
1519 data->connection_attempts = NULL; in cancel_all_attempts()
1521 g_slist_free_full (data->successful_connections, connection_attempt_unref); in cancel_all_attempts()
1522 data->successful_connections = NULL; in cancel_all_attempts()
1524 g_cancellable_cancel (data->enumeration_cancellable); in cancel_all_attempts()
1530 GSocketClientAsyncConnectData *data = attempt->data; in g_socket_client_async_connect_complete()
1532 g_assert (attempt->connection); in g_socket_client_async_connect_complete()
1533 g_assert (!data->completed); in g_socket_client_async_connect_complete()
1535 if (!G_IS_SOCKET_CONNECTION (attempt->connection)) in g_socket_client_async_connect_complete()
1539 wrapper_connection = g_tcp_wrapper_connection_new (attempt->connection, attempt->socket); in g_socket_client_async_connect_complete()
1540 g_object_unref (attempt->connection); in g_socket_client_async_connect_complete()
1541 attempt->connection = (GIOStream *)wrapper_connection; in g_socket_client_async_connect_complete()
1544 data->completed = TRUE; in g_socket_client_async_connect_complete()
1547 if (g_cancellable_set_error_if_cancelled (g_task_get_cancellable (data->task), &error)) in g_socket_client_async_connect_complete()
1550 g_socket_client_emit_event (data->client, G_SOCKET_CLIENT_COMPLETE, data->connectable, NULL); in g_socket_client_async_connect_complete()
1551 g_task_return_error (data->task, g_steal_pointer (&error)); in g_socket_client_async_connect_complete()
1556 …g_socket_client_emit_event (data->client, G_SOCKET_CLIENT_COMPLETE, data->connectable, attempt->co… in g_socket_client_async_connect_complete()
1557 g_task_return_pointer (data->task, g_steal_pointer (&attempt->connection), g_object_unref); in g_socket_client_async_connect_complete()
1561 g_object_unref (data->task); in g_socket_client_async_connect_complete()
1577 g_object_ref (data->task); in enumerator_next_async()
1579 if (!data->enumerated_at_least_once) in enumerator_next_async()
1580 g_socket_client_emit_event (data->client, G_SOCKET_CLIENT_RESOLVING, data->connectable, NULL); in enumerator_next_async()
1582 g_socket_address_enumerator_next_async (data->enumerator, in enumerator_next_async()
1583 data->enumeration_cancellable, in enumerator_next_async()
1596 GSocketClientAsyncConnectData *data = attempt->data; in g_socket_client_tls_handshake_callback()
1600 &data->error_info->tmp_error)) in g_socket_client_tls_handshake_callback()
1602 g_object_unref (attempt->connection); in g_socket_client_tls_handshake_callback()
1603 attempt->connection = G_IO_STREAM (object); in g_socket_client_tls_handshake_callback()
1606 …g_socket_client_emit_event (data->client, G_SOCKET_CLIENT_TLS_HANDSHAKED, data->connectable, attem… in g_socket_client_tls_handshake_callback()
1614 g_debug ("GSocketClient: TLS handshake failed: %s", data->error_info->tmp_error->message); in g_socket_client_tls_handshake_callback()
1615 consider_tmp_error (data->error_info, G_SOCKET_CLIENT_TLS_HANDSHAKING); in g_socket_client_tls_handshake_callback()
1623 GSocketClientAsyncConnectData *data = attempt->data; in g_socket_client_tls_handshake()
1626 if (!data->client->priv->tls) in g_socket_client_tls_handshake()
1633 tlsconn = g_tls_client_connection_new (attempt->connection, in g_socket_client_tls_handshake()
1634 data->connectable, in g_socket_client_tls_handshake()
1635 &data->error_info->tmp_error); in g_socket_client_tls_handshake()
1639 data->client->priv->tls_validation_flags); in g_socket_client_tls_handshake()
1640 …g_socket_client_emit_event (data->client, G_SOCKET_CLIENT_TLS_HANDSHAKING, data->connectable, G_IO… in g_socket_client_tls_handshake()
1643 g_task_get_cancellable (data->task), in g_socket_client_tls_handshake()
1651 consider_tmp_error (data->error_info, G_SOCKET_CLIENT_TLS_HANDSHAKING); in g_socket_client_tls_handshake()
1662 GSocketClientAsyncConnectData *data = attempt->data; in g_socket_client_proxy_connect_callback()
1664 g_object_unref (attempt->connection); in g_socket_client_proxy_connect_callback()
1665 attempt->connection = g_proxy_connect_finish (G_PROXY (object), in g_socket_client_proxy_connect_callback()
1667 &data->error_info->tmp_error); in g_socket_client_proxy_connect_callback()
1668 if (attempt->connection) in g_socket_client_proxy_connect_callback()
1670 …g_socket_client_emit_event (data->client, G_SOCKET_CLIENT_PROXY_NEGOTIATED, data->connectable, att… in g_socket_client_proxy_connect_callback()
1677 consider_tmp_error (data->error_info, G_SOCKET_CLIENT_PROXY_NEGOTIATING); in g_socket_client_proxy_connect_callback()
1686 g_debug ("GSocketClient: Connection failed: %s", error->message); in complete_connection_with_error()
1687 g_assert (!data->completed); in complete_connection_with_error()
1689 g_socket_client_emit_event (data->client, G_SOCKET_CLIENT_COMPLETE, data->connectable, NULL); in complete_connection_with_error()
1690 data->completed = TRUE; in complete_connection_with_error()
1692 g_task_return_error (data->task, error); in complete_connection_with_error()
1698 GTask *task = data->task; in task_completed_or_cancelled()
1702 if (data->completed) in task_completed_or_cancelled()
1720 if (data->connection_in_progress) in try_next_successful_connection()
1723 g_assert (data->successful_connections != NULL); in try_next_successful_connection()
1724 attempt = data->successful_connections->data; in try_next_successful_connection()
1726 data->successful_connections = g_slist_remove (data->successful_connections, attempt); in try_next_successful_connection()
1727 data->connection_in_progress = TRUE; in try_next_successful_connection()
1731 if (!attempt->proxy_addr) in try_next_successful_connection()
1737 protocol = g_proxy_address_get_protocol (attempt->proxy_addr); in try_next_successful_connection()
1742 if (!G_IS_TCP_CONNECTION (attempt->connection)) in try_next_successful_connection()
1744 g_critical ("Trying to proxy over non-TCP connection, this is " in try_next_successful_connection()
1747 g_set_error_literal (&data->error_info->tmp_error, in try_next_successful_connection()
1749 _("Proxying over a non-TCP connection is not supported.")); in try_next_successful_connection()
1750 consider_tmp_error (data->error_info, G_SOCKET_CLIENT_PROXY_NEGOTIATING); in try_next_successful_connection()
1752 else if (g_hash_table_contains (data->client->priv->app_proxies, protocol)) in try_next_successful_connection()
1761 GIOStream *connection = attempt->connection; in try_next_successful_connection()
1762 GProxyAddress *proxy_addr = attempt->proxy_addr; in try_next_successful_connection()
1764 …g_socket_client_emit_event (data->client, G_SOCKET_CLIENT_PROXY_NEGOTIATING, data->connectable, at… in try_next_successful_connection()
1769 g_task_get_cancellable (data->task), in try_next_successful_connection()
1777 g_set_error (&data->error_info->tmp_error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED, in try_next_successful_connection()
1780 consider_tmp_error (data->error_info, G_SOCKET_CLIENT_PROXY_NEGOTIATING); in try_next_successful_connection()
1783 data->connection_in_progress = FALSE; in try_next_successful_connection()
1785 return FALSE; /* All non-return paths are failures */ in try_next_successful_connection()
1793 data->connection_in_progress = FALSE; in try_next_connection_or_finish()
1795 if (data->connection_in_progress) in try_next_connection_or_finish()
1799 while (data->successful_connections) in try_next_connection_or_finish()
1805 if (!data->enumeration_completed) in try_next_connection_or_finish()
1811 complete_connection_with_error (data, g_steal_pointer (&data->error_info->best_error)); in try_next_connection_or_finish()
1820 GSocketClientAsyncConnectData *data = attempt->data; in g_socket_client_connected_callback()
1822 if (task_completed_or_cancelled (data) || g_cancellable_is_cancelled (attempt->cancellable)) in g_socket_client_connected_callback()
1824 g_object_unref (data->task); in g_socket_client_connected_callback()
1829 if (attempt->timeout_source) in g_socket_client_connected_callback()
1831 g_source_destroy (attempt->timeout_source); in g_socket_client_connected_callback()
1832 g_clear_pointer (&attempt->timeout_source, g_source_unref); in g_socket_client_connected_callback()
1836 result, &data->error_info->tmp_error)) in g_socket_client_connected_callback()
1838 if (!g_cancellable_is_cancelled (attempt->cancellable)) in g_socket_client_connected_callback()
1840 … g_debug ("GSocketClient: Connection attempt failed: %s", data->error_info->tmp_error->message); in g_socket_client_connected_callback()
1841 clarify_connect_error (data->error_info->tmp_error, data->connectable, attempt->address); in g_socket_client_connected_callback()
1842 consider_tmp_error (data->error_info, G_SOCKET_CLIENT_CONNECTING); in g_socket_client_connected_callback()
1849 g_clear_error (&data->error_info->tmp_error); in g_socket_client_connected_callback()
1850 g_object_unref (data->task); in g_socket_client_connected_callback()
1857 g_socket_connection_set_cached_remote_address ((GSocketConnection*)attempt->connection, NULL); in g_socket_client_connected_callback()
1859 …g_socket_client_emit_event (data->client, G_SOCKET_CLIENT_CONNECTED, data->connectable, attempt->c… in g_socket_client_connected_callback()
1862 g_socket_set_blocking (attempt->socket, TRUE); in g_socket_client_connected_callback()
1870 …data->successful_connections = g_slist_append (data->successful_connections, g_steal_pointer (&att… in g_socket_client_connected_callback()
1879 if (!attempt->data->enumeration_completed) in on_connection_attempt_timeout()
1882 enumerator_next_async (attempt->data, TRUE); in on_connection_attempt_timeout()
1885 g_clear_pointer (&attempt->timeout_source, g_source_unref); in on_connection_attempt_timeout()
1910 g_object_unref (data->task); in g_socket_client_enumerator_callback()
1914 address = g_socket_address_enumerator_next_finish (data->enumerator, in g_socket_client_enumerator_callback()
1915 result, &data->error_info->tmp_error); in g_socket_client_enumerator_callback()
1918 if (G_UNLIKELY (data->enumeration_completed)) in g_socket_client_enumerator_callback()
1921 data->enumeration_completed = TRUE; in g_socket_client_enumerator_callback()
1932 …if ((data->enumerated_at_least_once && !data->connection_attempts && !data->connection_in_progress… in g_socket_client_enumerator_callback()
1933 !data->enumerated_at_least_once) in g_socket_client_enumerator_callback()
1936 data->error_info->tmp_error ? data->error_info->tmp_error->message : NULL); in g_socket_client_enumerator_callback()
1937 consider_tmp_error (data->error_info, G_SOCKET_CLIENT_RESOLVING); in g_socket_client_enumerator_callback()
1938 g_assert (data->error_info->best_error); in g_socket_client_enumerator_callback()
1939 complete_connection_with_error (data, g_steal_pointer (&data->error_info->best_error)); in g_socket_client_enumerator_callback()
1943 g_object_unref (data->task); in g_socket_client_enumerator_callback()
1948 if (!data->enumerated_at_least_once) in g_socket_client_enumerator_callback()
1950 g_socket_client_emit_event (data->client, G_SOCKET_CLIENT_RESOLVED, in g_socket_client_enumerator_callback()
1951 data->connectable, NULL); in g_socket_client_enumerator_callback()
1952 data->enumerated_at_least_once = TRUE; in g_socket_client_enumerator_callback()
1955 socket = create_socket (data->client, address, &data->error_info->tmp_error); in g_socket_client_enumerator_callback()
1959 consider_tmp_error (data->error_info, G_SOCKET_CLIENT_CONNECTING); in g_socket_client_enumerator_callback()
1965 attempt->data = data; in g_socket_client_enumerator_callback()
1966 attempt->socket = socket; in g_socket_client_enumerator_callback()
1967 attempt->address = address; in g_socket_client_enumerator_callback()
1968 attempt->cancellable = g_cancellable_new (); in g_socket_client_enumerator_callback()
1969 attempt->connection = (GIOStream *)g_socket_connection_factory_create_connection (socket); in g_socket_client_enumerator_callback()
1970 attempt->timeout_source = g_timeout_source_new (HAPPY_EYEBALLS_CONNECTION_ATTEMPT_TIMEOUT_MS); in g_socket_client_enumerator_callback()
1972 if (G_IS_PROXY_ADDRESS (address) && data->client->priv->enable_proxy) in g_socket_client_enumerator_callback()
1973 attempt->proxy_addr = g_object_ref (G_PROXY_ADDRESS (address)); in g_socket_client_enumerator_callback()
1975 g_source_set_callback (attempt->timeout_source, on_connection_attempt_timeout, attempt, NULL); in g_socket_client_enumerator_callback()
1976 g_source_attach (attempt->timeout_source, g_task_get_context (data->task)); in g_socket_client_enumerator_callback()
1977 data->connection_attempts = g_slist_append (data->connection_attempts, attempt); in g_socket_client_enumerator_callback()
1979 if (g_task_get_cancellable (data->task)) in g_socket_client_enumerator_callback()
1980 … g_cancellable_connect (g_task_get_cancellable (data->task), G_CALLBACK (on_connection_cancelled), in g_socket_client_enumerator_callback()
1981 g_object_ref (attempt->cancellable), g_object_unref); in g_socket_client_enumerator_callback()
1983 g_socket_connection_set_cached_remote_address ((GSocketConnection *)attempt->connection, address); in g_socket_client_enumerator_callback()
1985 …g_socket_client_emit_event (data->client, G_SOCKET_CLIENT_CONNECTING, data->connectable, attempt->… in g_socket_client_enumerator_callback()
1986 g_socket_connection_connect_async (G_SOCKET_CONNECTION (attempt->connection), in g_socket_client_enumerator_callback()
1988 attempt->cancellable, in g_socket_client_enumerator_callback()
2006 * where IPv6 is broken by performing an IPv4 connection simultaneously
2029 data->client = client; in g_socket_client_connect_async()
2030 data->connectable = g_object_ref (connectable); in g_socket_client_connect_async()
2031 data->error_info = socket_client_error_info_new (); in g_socket_client_connect_async()
2035 data->enumerator = g_socket_connectable_proxy_enumerate (connectable); in g_socket_client_connect_async()
2036 if (client->priv->proxy_resolver && in g_socket_client_connect_async()
2037 G_IS_PROXY_ADDRESS_ENUMERATOR (data->enumerator)) in g_socket_client_connect_async()
2039 g_object_set (G_OBJECT (data->enumerator), in g_socket_client_connect_async()
2040 "proxy-resolver", client->priv->proxy_resolver, in g_socket_client_connect_async()
2045 data->enumerator = g_socket_connectable_enumerate (connectable); in g_socket_client_connect_async()
2048 which is simple enough but much of it is done in parallel to be as responsive in g_socket_client_connect_async()
2053 - This may be triggered multiple times by enumerator_next_async(). in g_socket_client_connect_async()
2054 - It also has its own cancellable (data->enumeration_cancellable). in g_socket_client_connect_async()
2055 - Enumeration is done lazily because GNetworkAddressAddressEnumerator in g_socket_client_connect_async()
2057 - If the first enumeration errors then the task errors. Otherwise all enumerations in g_socket_client_connect_async()
2061 - Each connection is independent and kept in a ConnectionAttempt object. in g_socket_client_connect_async()
2062 - They each hold a ref on the main task and have their own cancellable. in g_socket_client_connect_async()
2063 - Multiple attempts may happen in parallel as per Happy Eyeballs. in g_socket_client_connect_async()
2064 - Upon failure or timeouts more connection attempts are made. in g_socket_client_connect_async()
2065 - If no connections succeed the task errors. in g_socket_client_connect_async()
2066 - Upon success they are kept in a list of successful connections. in g_socket_client_connect_async()
2069 - These are done in serial. in g_socket_client_connect_async()
2070 - The reasoning here is that Happy Eyeballs is about making bad connections responsive in g_socket_client_connect_async()
2073 - Upon failure it will try the next TCP connection until it runs out and in g_socket_client_connect_async()
2075 - Upon success it cancels everything remaining (enumeration and connections) in g_socket_client_connect_async()
2079 data->task = g_task_new (client, cancellable, callback, user_data); in g_socket_client_connect_async()
2080 g_task_set_check_cancellable (data->task, FALSE); /* We handle this manually */ in g_socket_client_connect_async()
2081 g_task_set_source_tag (data->task, g_socket_client_connect_async); in g_socket_client_connect_async()
2082 g_task_set_task_data (data->task, data, (GDestroyNotify)g_socket_client_async_connect_data_free); in g_socket_client_connect_async()
2084 data->enumeration_cancellable = g_cancellable_new (); in g_socket_client_connect_async()
2087 g_object_ref (data->enumeration_cancellable), g_object_unref); in g_socket_client_connect_async()
2142 * @service: the name of the service to connect to
2155 const gchar *service, in g_socket_client_connect_to_service_async() argument
2162 connectable = g_network_service_new (service, "tcp", domain); in g_socket_client_connect_to_service_async()
2331 g_hash_table_add (client->priv->app_proxies, g_strdup (protocol)); in g_socket_client_add_application_proxy()