Class: Gio::SocketClient
- Inherits:
-
Object
- Object
- Gio::SocketClient
- Defined in:
- (unknown)
Instance Method Summary collapse
-
#add_application_proxy(protocol) ⇒ nil
Enable proxy protocols to be handled by the application.
-
#connect(connectable, cancellable) ⇒ Gio::SocketConnection
Tries to resolve the connectable and make a network connection to it.
-
#connect_async(connectable, cancellable, callback, user_data) ⇒ nil
This is the asynchronous version of g_socket_client_connect().
-
#connect_finish(result) ⇒ Gio::SocketConnection
Finishes an async connect operation.
-
#connect_to_host(host_and_port, default_port, cancellable) ⇒ Gio::SocketConnection
This is a helper function for g_socket_client_connect().
-
#connect_to_host_async(host_and_port, default_port, cancellable, callback, user_data) ⇒ nil
This is the asynchronous version of g_socket_client_connect_to_host().
-
#connect_to_host_finish(result) ⇒ Gio::SocketConnection
Finishes an async connect operation.
-
#connect_to_service(domain, service, cancellable) ⇒ Gio::SocketConnection
Attempts to create a TCP connection to a service.
-
#connect_to_service_async(domain, service, cancellable, callback, user_data) ⇒ nil
This is the asynchronous version of g_socket_client_connect_to_service().
-
#connect_to_service_finish(result) ⇒ Gio::SocketConnection
Finishes an async connect operation.
-
#connect_to_uri(uri, default_port, cancellable) ⇒ Gio::SocketConnection
This is a helper function for g_socket_client_connect().
-
#connect_to_uri_async(uri, default_port, cancellable, callback, user_data) ⇒ nil
This is the asynchronous version of g_socket_client_connect_to_uri().
-
#connect_to_uri_finish(result) ⇒ Gio::SocketConnection
Finishes an async connect operation.
-
#enable_proxy ⇒ TrueClass
Gets the proxy enable state; see g_socket_client_set_enable_proxy().
- #enable_proxy=(enable_proxy) ⇒ TrueClass
-
#enable_proxy? ⇒ TrueClass
Enable-proxy.
-
#family ⇒ Gio::SocketFamily
Family.
- #family=(family) ⇒ Gio::SocketFamily
-
#local_address ⇒ Gio::SocketAddress
Local-address.
- #local_address=(local_address) ⇒ Gio::SocketAddress
-
#new ⇒ Gio::SocketClient
Creates a new GSocket::Client with the default options.
-
#protocol ⇒ Gio::SocketProtocol
Protocol.
- #protocol=(protocol) ⇒ Gio::SocketProtocol
-
#proxy_resolver ⇒ Gio::ProxyResolver
The proxy resolver to use.
-
#proxy_resolver=(proxy_resolver) ⇒ Gio::ProxyResolver
The proxy resolver to use.
-
#socket_type ⇒ Gio::SocketType
Gets the socket type of the socket client.
-
#socket_type=(type) ⇒ nil
Sets the socket type of the socket client.
-
#timeout ⇒ Integer
Timeout.
- #timeout=(timeout) ⇒ Integer
-
#tls ⇒ TrueClass
Gets whether client creates TLS connections.
- #tls=(tls) ⇒ TrueClass
-
#tls? ⇒ TrueClass
Tls.
-
#tls_validation_flags ⇒ Gio::TlsCertificateFlags
Tls-validation-flags.
- #tls_validation_flags=(tls_validation_flags) ⇒ Gio::TlsCertificateFlags
-
#type ⇒ Gio::SocketType
Type.
- #type=(type) ⇒ Gio::SocketType
Instance Method Details
#add_application_proxy(protocol) ⇒ nil
Enable proxy protocols to be handled by the application. When the indicated proxy protocol is returned by the GProxy::Resolver, GSocket::Client will consider this protocol as supported but will not try to find a #GProxy instance to handle handshaking. The application must check for this case by calling g_socket_connection_get_remote_address() on the returned GSocket::Connection, and seeing if it’s a #GProxyAddress of the appropriate type, to determine whether or not it needs to handle the proxy handshaking itself.
This should be used for proxy protocols that are dialects of another protocol such as HTTP proxy. It also allows cohabitation of proxy protocols that are reused between protocols. A good example is HTTP. It can be used to proxy HTTP, FTP and Gopher and can also be use as generic socket proxy through the HTTP CONNECT method.
When the proxy is detected as being an application proxy, TLS handshake will be skipped. This is required to let the application do the proxy specific handshake.
#connect(connectable, cancellable) ⇒ Gio::SocketConnection
Tries to resolve the connectable and make a network connection to it.
Upon a successful connection, a new GSocket::Connection is constructed and returned. The caller owns this new object and must drop their reference to it when finished with it.
The type of the GSocket::Connection object returned depends on the type of the underlying socket that is used. For instance, for a TCP/IP connection it will be a GTcp::Connection.
The socket created will be the same family as the address that the connectable resolves to, unless family is set with g_socket_client_set_family() or indirectly via g_socket_client_set_local_address(). The socket type defaults to %G_SOCKET_TYPE_STREAM but can be set with g_socket_client_set_socket_type().
If a local address is specified with g_socket_client_set_local_address() the socket will be bound to this address before connecting.
#connect_async(connectable, cancellable, callback, user_data) ⇒ nil
This is the asynchronous version of g_socket_client_connect().
When the operation is finished callback will be called. You can then call g_socket_client_connect_finish() to get the result of the operation.
#connect_finish(result) ⇒ Gio::SocketConnection
Finishes an async connect operation. See g_socket_client_connect_async()
#connect_to_host(host_and_port, default_port, cancellable) ⇒ Gio::SocketConnection
This is a helper function for g_socket_client_connect().
Attempts to create a TCP connection to the named host.
host_and_port may be in any of a number of recognized formats; an IPv6 address, an IPv4 address, or a domain name (in which case a DNS lookup is performed). Quoting with [] is supported for all address types. A port override may be specified in the usual way with a colon. Ports may be given as decimal numbers or symbolic names (in which case an /etc/services lookup is performed).
If no port override is given in host_and_port then default_port will be used as the port number to connect to.
In general, host_and_port is expected to be provided by the user (allowing them to give the hostname, and a port override if necessary) and default_port is expected to be provided by the application.
In the case that an IP address is given, a single connection attempt is made. In the case that a name is given, multiple connection attempts may be made, in turn and according to the number of address records in DNS, until a connection succeeds.
Upon a successful connection, a new GSocket::Connection is constructed and returned. The caller owns this new object and must drop their reference to it when finished with it.
In the event of any failure (DNS error, service not found, no hosts connectable) nil is returned and error (if non-nil) is set accordingly.
#connect_to_host_async(host_and_port, default_port, cancellable, callback, user_data) ⇒ nil
This is the asynchronous version of g_socket_client_connect_to_host().
When the operation is finished callback will be called. You can then call g_socket_client_connect_to_host_finish() to get the result of the operation.
#connect_to_host_finish(result) ⇒ Gio::SocketConnection
Finishes an async connect operation. See g_socket_client_connect_to_host_async()
#connect_to_service(domain, service, cancellable) ⇒ Gio::SocketConnection
Attempts to create a TCP connection to a service.
This call looks up the SRV record for service at domain for the “tcp” protocol. It then attempts to connect, in turn, to each of the hosts providing the service until either a connection succeeds or there are no hosts remaining.
Upon a successful connection, a new GSocket::Connection is constructed and returned. The caller owns this new object and must drop their reference to it when finished with it.
In the event of any failure (DNS error, service not found, no hosts connectable) nil is returned and error (if non-nil) is set accordingly.
#connect_to_service_async(domain, service, cancellable, callback, user_data) ⇒ nil
This is the asynchronous version of g_socket_client_connect_to_service().
#connect_to_service_finish(result) ⇒ Gio::SocketConnection
Finishes an async connect operation. See g_socket_client_connect_to_service_async()
#connect_to_uri(uri, default_port, cancellable) ⇒ Gio::SocketConnection
This is a helper function for g_socket_client_connect().
Attempts to create a TCP connection with a network URI.
uri may be any valid URI containing an “authority” (hostname/port) component. If a port is not specified in the URI, default_port will be used. TLS will be negotiated if GSocket::Client:tls is true. (GSocket::Client does not know to automatically assume TLS for certain URI schemes.)
Using this rather than g_socket_client_connect() or g_socket_client_connect_to_host() allows GSocket::Client to determine when to use application-specific proxy protocols.
Upon a successful connection, a new GSocket::Connection is constructed and returned. The caller owns this new object and must drop their reference to it when finished with it.
In the event of any failure (DNS error, service not found, no hosts connectable) nil is returned and error (if non-nil) is set accordingly.
#connect_to_uri_async(uri, default_port, cancellable, callback, user_data) ⇒ nil
This is the asynchronous version of g_socket_client_connect_to_uri().
When the operation is finished callback will be called. You can then call g_socket_client_connect_to_uri_finish() to get the result of the operation.
#connect_to_uri_finish(result) ⇒ Gio::SocketConnection
Finishes an async connect operation. See g_socket_client_connect_to_uri_async()
#enable_proxy ⇒ TrueClass
Gets the proxy enable state; see g_socket_client_set_enable_proxy()
#enable_proxy=(enable_proxy) ⇒ TrueClass
#enable_proxy? ⇒ TrueClass
Returns enable-proxy.
#family ⇒ Gio::SocketFamily
Returns family.
#family=(family) ⇒ Gio::SocketFamily
#local_address ⇒ Gio::SocketAddress
Returns local-address.
#local_address=(local_address) ⇒ Gio::SocketAddress
#new ⇒ Gio::SocketClient
Creates a new GSocket::Client with the default options.
#protocol ⇒ Gio::SocketProtocol
Returns protocol.
#protocol=(protocol) ⇒ Gio::SocketProtocol
#proxy_resolver ⇒ Gio::ProxyResolver
The proxy resolver to use
#proxy_resolver=(proxy_resolver) ⇒ Gio::ProxyResolver
The proxy resolver to use
#socket_type ⇒ Gio::SocketType
Gets the socket type of the socket client.
See g_socket_client_set_socket_type() for details.
#socket_type=(type) ⇒ nil
Sets the socket type of the socket client. The sockets created by this object will be of the specified type.
It doesn’t make sense to specify a type of %G_SOCKET_TYPE_DATAGRAM, as GSocketClient is used for connection oriented services.
#timeout ⇒ Integer
Returns timeout.
#timeout=(timeout) ⇒ Integer
#tls ⇒ TrueClass
Gets whether client creates TLS connections. See g_socket_client_set_tls() for details.
#tls=(tls) ⇒ TrueClass
#tls? ⇒ TrueClass
Returns tls.
#tls_validation_flags ⇒ Gio::TlsCertificateFlags
Returns tls-validation-flags.
#tls_validation_flags=(tls_validation_flags) ⇒ Gio::TlsCertificateFlags
#type ⇒ Gio::SocketType
Returns type.