Copyright | Will Thompson, Iñaki García Etxebarria and Jonas Platte |
---|---|
License | LGPL-2.1 |
Maintainer | Iñaki García Etxebarria (garetxe@gmail.com) |
Safe Haskell | None |
Language | Haskell2010 |
- Exported types
- Methods
- addApplicationProxy
- connect
- connectAsync
- connectFinish
- connectToHost
- connectToHostAsync
- connectToHostFinish
- connectToService
- connectToServiceAsync
- connectToServiceFinish
- connectToUri
- connectToUriAsync
- connectToUriFinish
- getEnableProxy
- getFamily
- getLocalAddress
- getProtocol
- getProxyResolver
- getSocketType
- getTimeout
- getTls
- getTlsValidationFlags
- new
- setEnableProxy
- setFamily
- setLocalAddress
- setProtocol
- setProxyResolver
- setSocketType
- setTimeout
- setTls
- setTlsValidationFlags
- Properties
- Signals
SocketClient
is a lightweight high-level utility class for connecting to
a network host using a connection oriented socket type.
You create a SocketClient
object, set any options you want, and then
call a sync or async connect operation, which returns a SocketConnection
subclass on success.
The type of the SocketConnection
object returned depends on the type of
the underlying socket that is in use. For instance, for a TCP/IP connection
it will be a TcpConnection
.
As SocketClient
is a lightweight object, you don't need to cache it. You
can just create a new one any time you need one.
- newtype SocketClient = SocketClient (ManagedPtr SocketClient)
- class GObject o => IsSocketClient o
- toSocketClient :: IsSocketClient o => o -> IO SocketClient
- noSocketClient :: Maybe SocketClient
- data SocketClientAddApplicationProxyMethodInfo
- socketClientAddApplicationProxy :: (HasCallStack, MonadIO m, IsSocketClient a) => a -> Text -> m ()
- data SocketClientConnectMethodInfo
- socketClientConnect :: (HasCallStack, MonadIO m, IsSocketClient a, IsSocketConnectable b, IsCancellable c) => a -> b -> Maybe c -> m SocketConnection
- data SocketClientConnectAsyncMethodInfo
- socketClientConnectAsync :: (HasCallStack, MonadIO m, IsSocketClient a, IsSocketConnectable b, IsCancellable c) => a -> b -> Maybe c -> Maybe AsyncReadyCallback -> m ()
- data SocketClientConnectFinishMethodInfo
- socketClientConnectFinish :: (HasCallStack, MonadIO m, IsSocketClient a, IsAsyncResult b) => a -> b -> m SocketConnection
- data SocketClientConnectToHostMethodInfo
- socketClientConnectToHost :: (HasCallStack, MonadIO m, IsSocketClient a, IsCancellable b) => a -> Text -> Word16 -> Maybe b -> m SocketConnection
- data SocketClientConnectToHostAsyncMethodInfo
- socketClientConnectToHostAsync :: (HasCallStack, MonadIO m, IsSocketClient a, IsCancellable b) => a -> Text -> Word16 -> Maybe b -> Maybe AsyncReadyCallback -> m ()
- data SocketClientConnectToHostFinishMethodInfo
- socketClientConnectToHostFinish :: (HasCallStack, MonadIO m, IsSocketClient a, IsAsyncResult b) => a -> b -> m SocketConnection
- data SocketClientConnectToServiceMethodInfo
- socketClientConnectToService :: (HasCallStack, MonadIO m, IsSocketClient a, IsCancellable b) => a -> Text -> Text -> Maybe b -> m SocketConnection
- data SocketClientConnectToServiceAsyncMethodInfo
- socketClientConnectToServiceAsync :: (HasCallStack, MonadIO m, IsSocketClient a, IsCancellable b) => a -> Text -> Text -> Maybe b -> Maybe AsyncReadyCallback -> m ()
- data SocketClientConnectToServiceFinishMethodInfo
- socketClientConnectToServiceFinish :: (HasCallStack, MonadIO m, IsSocketClient a, IsAsyncResult b) => a -> b -> m SocketConnection
- data SocketClientConnectToUriMethodInfo
- socketClientConnectToUri :: (HasCallStack, MonadIO m, IsSocketClient a, IsCancellable b) => a -> Text -> Word16 -> Maybe b -> m SocketConnection
- data SocketClientConnectToUriAsyncMethodInfo
- socketClientConnectToUriAsync :: (HasCallStack, MonadIO m, IsSocketClient a, IsCancellable b) => a -> Text -> Word16 -> Maybe b -> Maybe AsyncReadyCallback -> m ()
- data SocketClientConnectToUriFinishMethodInfo
- socketClientConnectToUriFinish :: (HasCallStack, MonadIO m, IsSocketClient a, IsAsyncResult b) => a -> b -> m SocketConnection
- data SocketClientGetEnableProxyMethodInfo
- socketClientGetEnableProxy :: (HasCallStack, MonadIO m, IsSocketClient a) => a -> m Bool
- data SocketClientGetFamilyMethodInfo
- socketClientGetFamily :: (HasCallStack, MonadIO m, IsSocketClient a) => a -> m SocketFamily
- data SocketClientGetLocalAddressMethodInfo
- socketClientGetLocalAddress :: (HasCallStack, MonadIO m, IsSocketClient a) => a -> m SocketAddress
- data SocketClientGetProtocolMethodInfo
- socketClientGetProtocol :: (HasCallStack, MonadIO m, IsSocketClient a) => a -> m SocketProtocol
- data SocketClientGetProxyResolverMethodInfo
- socketClientGetProxyResolver :: (HasCallStack, MonadIO m, IsSocketClient a) => a -> m ProxyResolver
- data SocketClientGetSocketTypeMethodInfo
- socketClientGetSocketType :: (HasCallStack, MonadIO m, IsSocketClient a) => a -> m SocketType
- data SocketClientGetTimeoutMethodInfo
- socketClientGetTimeout :: (HasCallStack, MonadIO m, IsSocketClient a) => a -> m Word32
- data SocketClientGetTlsMethodInfo
- socketClientGetTls :: (HasCallStack, MonadIO m, IsSocketClient a) => a -> m Bool
- data SocketClientGetTlsValidationFlagsMethodInfo
- socketClientGetTlsValidationFlags :: (HasCallStack, MonadIO m, IsSocketClient a) => a -> m [TlsCertificateFlags]
- socketClientNew :: (HasCallStack, MonadIO m) => m SocketClient
- data SocketClientSetEnableProxyMethodInfo
- socketClientSetEnableProxy :: (HasCallStack, MonadIO m, IsSocketClient a) => a -> Bool -> m ()
- data SocketClientSetFamilyMethodInfo
- socketClientSetFamily :: (HasCallStack, MonadIO m, IsSocketClient a) => a -> SocketFamily -> m ()
- data SocketClientSetLocalAddressMethodInfo
- socketClientSetLocalAddress :: (HasCallStack, MonadIO m, IsSocketClient a, IsSocketAddress b) => a -> Maybe b -> m ()
- data SocketClientSetProtocolMethodInfo
- socketClientSetProtocol :: (HasCallStack, MonadIO m, IsSocketClient a) => a -> SocketProtocol -> m ()
- data SocketClientSetProxyResolverMethodInfo
- socketClientSetProxyResolver :: (HasCallStack, MonadIO m, IsSocketClient a, IsProxyResolver b) => a -> Maybe b -> m ()
- data SocketClientSetSocketTypeMethodInfo
- socketClientSetSocketType :: (HasCallStack, MonadIO m, IsSocketClient a) => a -> SocketType -> m ()
- data SocketClientSetTimeoutMethodInfo
- socketClientSetTimeout :: (HasCallStack, MonadIO m, IsSocketClient a) => a -> Word32 -> m ()
- data SocketClientSetTlsMethodInfo
- socketClientSetTls :: (HasCallStack, MonadIO m, IsSocketClient a) => a -> Bool -> m ()
- data SocketClientSetTlsValidationFlagsMethodInfo
- socketClientSetTlsValidationFlags :: (HasCallStack, MonadIO m, IsSocketClient a) => a -> [TlsCertificateFlags] -> m ()
- data SocketClientEnableProxyPropertyInfo
- constructSocketClientEnableProxy :: IsSocketClient o => Bool -> IO (GValueConstruct o)
- getSocketClientEnableProxy :: (MonadIO m, IsSocketClient o) => o -> m Bool
- setSocketClientEnableProxy :: (MonadIO m, IsSocketClient o) => o -> Bool -> m ()
- socketClientEnableProxy :: AttrLabelProxy "enableProxy"
- data SocketClientFamilyPropertyInfo
- constructSocketClientFamily :: IsSocketClient o => SocketFamily -> IO (GValueConstruct o)
- getSocketClientFamily :: (MonadIO m, IsSocketClient o) => o -> m SocketFamily
- setSocketClientFamily :: (MonadIO m, IsSocketClient o) => o -> SocketFamily -> m ()
- socketClientFamily :: AttrLabelProxy "family"
- data SocketClientLocalAddressPropertyInfo
- clearSocketClientLocalAddress :: (MonadIO m, IsSocketClient o) => o -> m ()
- constructSocketClientLocalAddress :: (IsSocketClient o, IsSocketAddress a) => a -> IO (GValueConstruct o)
- getSocketClientLocalAddress :: (MonadIO m, IsSocketClient o) => o -> m SocketAddress
- setSocketClientLocalAddress :: (MonadIO m, IsSocketClient o, IsSocketAddress a) => o -> a -> m ()
- socketClientLocalAddress :: AttrLabelProxy "localAddress"
- data SocketClientProtocolPropertyInfo
- constructSocketClientProtocol :: IsSocketClient o => SocketProtocol -> IO (GValueConstruct o)
- getSocketClientProtocol :: (MonadIO m, IsSocketClient o) => o -> m SocketProtocol
- setSocketClientProtocol :: (MonadIO m, IsSocketClient o) => o -> SocketProtocol -> m ()
- socketClientProtocol :: AttrLabelProxy "protocol"
- data SocketClientProxyResolverPropertyInfo
- clearSocketClientProxyResolver :: (MonadIO m, IsSocketClient o) => o -> m ()
- constructSocketClientProxyResolver :: (IsSocketClient o, IsProxyResolver a) => a -> IO (GValueConstruct o)
- getSocketClientProxyResolver :: (MonadIO m, IsSocketClient o) => o -> m ProxyResolver
- setSocketClientProxyResolver :: (MonadIO m, IsSocketClient o, IsProxyResolver a) => o -> a -> m ()
- socketClientProxyResolver :: AttrLabelProxy "proxyResolver"
- data SocketClientTimeoutPropertyInfo
- constructSocketClientTimeout :: IsSocketClient o => Word32 -> IO (GValueConstruct o)
- getSocketClientTimeout :: (MonadIO m, IsSocketClient o) => o -> m Word32
- setSocketClientTimeout :: (MonadIO m, IsSocketClient o) => o -> Word32 -> m ()
- socketClientTimeout :: AttrLabelProxy "timeout"
- data SocketClientTlsPropertyInfo
- constructSocketClientTls :: IsSocketClient o => Bool -> IO (GValueConstruct o)
- getSocketClientTls :: (MonadIO m, IsSocketClient o) => o -> m Bool
- setSocketClientTls :: (MonadIO m, IsSocketClient o) => o -> Bool -> m ()
- socketClientTls :: AttrLabelProxy "tls"
- data SocketClientTlsValidationFlagsPropertyInfo
- constructSocketClientTlsValidationFlags :: IsSocketClient o => [TlsCertificateFlags] -> IO (GValueConstruct o)
- getSocketClientTlsValidationFlags :: (MonadIO m, IsSocketClient o) => o -> m [TlsCertificateFlags]
- setSocketClientTlsValidationFlags :: (MonadIO m, IsSocketClient o) => o -> [TlsCertificateFlags] -> m ()
- socketClientTlsValidationFlags :: AttrLabelProxy "tlsValidationFlags"
- data SocketClientTypePropertyInfo
- constructSocketClientType :: IsSocketClient o => SocketType -> IO (GValueConstruct o)
- getSocketClientType :: (MonadIO m, IsSocketClient o) => o -> m SocketType
- setSocketClientType :: (MonadIO m, IsSocketClient o) => o -> SocketType -> m ()
- socketClientType :: AttrLabelProxy "type"
- type C_SocketClientEventCallback = Ptr () -> CUInt -> Ptr SocketConnectable -> Ptr IOStream -> Ptr () -> IO ()
- type SocketClientEventCallback = SocketClientEvent -> SocketConnectable -> Maybe IOStream -> IO ()
- data SocketClientEventSignalInfo
- afterSocketClientEvent :: (IsSocketClient a, MonadIO m) => a -> SocketClientEventCallback -> m SignalHandlerId
- genClosure_SocketClientEvent :: SocketClientEventCallback -> IO Closure
- mk_SocketClientEventCallback :: C_SocketClientEventCallback -> IO (FunPtr C_SocketClientEventCallback)
- noSocketClientEventCallback :: Maybe SocketClientEventCallback
- onSocketClientEvent :: (IsSocketClient a, MonadIO m) => a -> SocketClientEventCallback -> m SignalHandlerId
- wrap_SocketClientEventCallback :: SocketClientEventCallback -> Ptr () -> CUInt -> Ptr SocketConnectable -> Ptr IOStream -> Ptr () -> IO ()
Exported types
newtype SocketClient Source #
GObject SocketClient Source # | |
IsObject SocketClient Source # | |
IsSocketClient SocketClient Source # | |
((~) * info (ResolveSocketClientMethod t SocketClient), MethodInfo * info SocketClient p) => IsLabel t (SocketClient -> p) Source # | |
((~) * info (ResolveSocketClientMethod t SocketClient), MethodInfo * info SocketClient p) => IsLabelProxy t (SocketClient -> p) Source # | |
HasAttributeList * SocketClient Source # | |
type AttributeList SocketClient Source # | |
type SignalList SocketClient Source # | |
class GObject o => IsSocketClient o Source #
toSocketClient :: IsSocketClient o => o -> IO SocketClient Source #
Methods
addApplicationProxy
data SocketClientAddApplicationProxyMethodInfo Source #
((~) * signature (Text -> m ()), MonadIO m, IsSocketClient a) => MethodInfo * SocketClientAddApplicationProxyMethodInfo a signature Source # | |
socketClientAddApplicationProxy Source #
:: (HasCallStack, MonadIO m, IsSocketClient a) | |
=> a |
|
-> Text |
|
-> m () |
Enable proxy protocols to be handled by the application. When the
indicated proxy protocol is returned by the ProxyResolver
,
SocketClient
will consider this protocol as supported but will
not try to find a Proxy
instance to handle handshaking. The
application must check for this case by calling
socketConnectionGetRemoteAddress
on the returned
SocketConnection
, and seeing if it's a ProxyAddress
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
data SocketClientConnectMethodInfo Source #
((~) * signature (b -> Maybe c -> m SocketConnection), MonadIO m, IsSocketClient a, IsSocketConnectable b, IsCancellable c) => MethodInfo * SocketClientConnectMethodInfo a signature Source # | |
:: (HasCallStack, MonadIO m, IsSocketClient a, IsSocketConnectable b, IsCancellable c) | |
=> a |
|
-> b |
|
-> Maybe c |
|
-> m SocketConnection | Returns: a |
Tries to resolve the connectable
and make a network connection to it.
Upon a successful connection, a new SocketConnection
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 SocketConnection
object returned depends on the type of
the underlying socket that is used. For instance, for a TCP/IP connection
it will be a TcpConnection
.
The socket created will be the same family as the address that the
connectable
resolves to, unless family is set with socketClientSetFamily
or indirectly via socketClientSetLocalAddress
. The socket type
defaults to SocketTypeStream
but can be set with
socketClientSetSocketType
.
If a local address is specified with socketClientSetLocalAddress
the
socket will be bound to this address before connecting.
Since: 2.22
connectAsync
data SocketClientConnectAsyncMethodInfo Source #
((~) * signature (b -> Maybe c -> Maybe AsyncReadyCallback -> m ()), MonadIO m, IsSocketClient a, IsSocketConnectable b, IsCancellable c) => MethodInfo * SocketClientConnectAsyncMethodInfo a signature Source # | |
socketClientConnectAsync Source #
:: (HasCallStack, MonadIO m, IsSocketClient a, IsSocketConnectable b, IsCancellable c) | |
=> a |
|
-> b |
|
-> Maybe c |
|
-> Maybe AsyncReadyCallback |
|
-> m () |
This is the asynchronous version of socketClientConnect
.
When the operation is finished callback
will be
called. You can then call socketClientConnectFinish
to get
the result of the operation.
Since: 2.22
connectFinish
data SocketClientConnectFinishMethodInfo Source #
((~) * signature (b -> m SocketConnection), MonadIO m, IsSocketClient a, IsAsyncResult b) => MethodInfo * SocketClientConnectFinishMethodInfo a signature Source # | |
socketClientConnectFinish Source #
:: (HasCallStack, MonadIO m, IsSocketClient a, IsAsyncResult b) | |
=> a |
|
-> b |
|
-> m SocketConnection | Returns: a |
Finishes an async connect operation. See socketClientConnectAsync
Since: 2.22
connectToHost
data SocketClientConnectToHostMethodInfo Source #
((~) * signature (Text -> Word16 -> Maybe b -> m SocketConnection), MonadIO m, IsSocketClient a, IsCancellable b) => MethodInfo * SocketClientConnectToHostMethodInfo a signature Source # | |
socketClientConnectToHost Source #
:: (HasCallStack, MonadIO m, IsSocketClient a, IsCancellable b) | |
=> a |
|
-> Text |
|
-> Word16 |
|
-> Maybe b |
|
-> m SocketConnection | Returns: a |
This is a helper function for socketClientConnect
.
Attempts to create a TCP connection to the named host.
hostAndPort
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 hostAndPort
then defaultPort
will be
used as the port number to connect to.
In general, hostAndPort
is expected to be provided by the user (allowing
them to give the hostname, and a port override if necessary) and
defaultPort
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 SocketConnection
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) Nothing
is returned and error
(if non-Nothing
) is set
accordingly.
Since: 2.22
connectToHostAsync
data SocketClientConnectToHostAsyncMethodInfo Source #
((~) * signature (Text -> Word16 -> Maybe b -> Maybe AsyncReadyCallback -> m ()), MonadIO m, IsSocketClient a, IsCancellable b) => MethodInfo * SocketClientConnectToHostAsyncMethodInfo a signature Source # | |
socketClientConnectToHostAsync Source #
:: (HasCallStack, MonadIO m, IsSocketClient a, IsCancellable b) | |
=> a |
|
-> Text |
|
-> Word16 |
|
-> Maybe b |
|
-> Maybe AsyncReadyCallback |
|
-> m () |
This is the asynchronous version of socketClientConnectToHost
.
When the operation is finished callback
will be
called. You can then call socketClientConnectToHostFinish
to get
the result of the operation.
Since: 2.22
connectToHostFinish
data SocketClientConnectToHostFinishMethodInfo Source #
((~) * signature (b -> m SocketConnection), MonadIO m, IsSocketClient a, IsAsyncResult b) => MethodInfo * SocketClientConnectToHostFinishMethodInfo a signature Source # | |
socketClientConnectToHostFinish Source #
:: (HasCallStack, MonadIO m, IsSocketClient a, IsAsyncResult b) | |
=> a |
|
-> b |
|
-> m SocketConnection | Returns: a |
Finishes an async connect operation. See socketClientConnectToHostAsync
Since: 2.22
connectToService
data SocketClientConnectToServiceMethodInfo Source #
((~) * signature (Text -> Text -> Maybe b -> m SocketConnection), MonadIO m, IsSocketClient a, IsCancellable b) => MethodInfo * SocketClientConnectToServiceMethodInfo a signature Source # | |
socketClientConnectToService Source #
:: (HasCallStack, MonadIO m, IsSocketClient a, IsCancellable b) | |
=> a |
|
-> Text |
|
-> Text |
|
-> Maybe b |
|
-> m SocketConnection | Returns: a |
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 SocketConnection
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) Nothing
is returned and error
(if non-Nothing
) is set
accordingly.
connectToServiceAsync
data SocketClientConnectToServiceAsyncMethodInfo Source #
((~) * signature (Text -> Text -> Maybe b -> Maybe AsyncReadyCallback -> m ()), MonadIO m, IsSocketClient a, IsCancellable b) => MethodInfo * SocketClientConnectToServiceAsyncMethodInfo a signature Source # | |
socketClientConnectToServiceAsync Source #
:: (HasCallStack, MonadIO m, IsSocketClient a, IsCancellable b) | |
=> a |
|
-> Text |
|
-> Text |
|
-> Maybe b |
|
-> Maybe AsyncReadyCallback |
|
-> m () |
This is the asynchronous version of
socketClientConnectToService
.
Since: 2.22
connectToServiceFinish
data SocketClientConnectToServiceFinishMethodInfo Source #
((~) * signature (b -> m SocketConnection), MonadIO m, IsSocketClient a, IsAsyncResult b) => MethodInfo * SocketClientConnectToServiceFinishMethodInfo a signature Source # | |
socketClientConnectToServiceFinish Source #
:: (HasCallStack, MonadIO m, IsSocketClient a, IsAsyncResult b) | |
=> a |
|
-> b |
|
-> m SocketConnection | Returns: a |
Finishes an async connect operation. See socketClientConnectToServiceAsync
Since: 2.22
connectToUri
data SocketClientConnectToUriMethodInfo Source #
((~) * signature (Text -> Word16 -> Maybe b -> m SocketConnection), MonadIO m, IsSocketClient a, IsCancellable b) => MethodInfo * SocketClientConnectToUriMethodInfo a signature Source # | |
socketClientConnectToUri Source #
:: (HasCallStack, MonadIO m, IsSocketClient a, IsCancellable b) | |
=> a |
|
-> Text |
|
-> Word16 |
|
-> Maybe b |
|
-> m SocketConnection | Returns: a |
This is a helper function for socketClientConnect
.
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, defaultPort
will be used. TLS will be negotiated if SocketClient
:tls
is True
.
(SocketClient
does not know to automatically assume TLS for
certain URI schemes.)
Using this rather than socketClientConnect
or
socketClientConnectToHost
allows SocketClient
to
determine when to use application-specific proxy protocols.
Upon a successful connection, a new SocketConnection
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) Nothing
is returned and error
(if non-Nothing
) is set
accordingly.
Since: 2.26
connectToUriAsync
data SocketClientConnectToUriAsyncMethodInfo Source #
((~) * signature (Text -> Word16 -> Maybe b -> Maybe AsyncReadyCallback -> m ()), MonadIO m, IsSocketClient a, IsCancellable b) => MethodInfo * SocketClientConnectToUriAsyncMethodInfo a signature Source # | |
socketClientConnectToUriAsync Source #
:: (HasCallStack, MonadIO m, IsSocketClient a, IsCancellable b) | |
=> a |
|
-> Text |
|
-> Word16 |
|
-> Maybe b |
|
-> Maybe AsyncReadyCallback |
|
-> m () |
This is the asynchronous version of socketClientConnectToUri
.
When the operation is finished callback
will be
called. You can then call socketClientConnectToUriFinish
to get
the result of the operation.
Since: 2.26
connectToUriFinish
data SocketClientConnectToUriFinishMethodInfo Source #
((~) * signature (b -> m SocketConnection), MonadIO m, IsSocketClient a, IsAsyncResult b) => MethodInfo * SocketClientConnectToUriFinishMethodInfo a signature Source # | |
socketClientConnectToUriFinish Source #
:: (HasCallStack, MonadIO m, IsSocketClient a, IsAsyncResult b) | |
=> a |
|
-> b |
|
-> m SocketConnection | Returns: a |
Finishes an async connect operation. See socketClientConnectToUriAsync
Since: 2.26
getEnableProxy
data SocketClientGetEnableProxyMethodInfo Source #
((~) * signature (m Bool), MonadIO m, IsSocketClient a) => MethodInfo * SocketClientGetEnableProxyMethodInfo a signature Source # | |
socketClientGetEnableProxy Source #
:: (HasCallStack, MonadIO m, IsSocketClient a) | |
=> a |
|
-> m Bool | Returns: whether proxying is enabled |
Gets the proxy enable state; see socketClientSetEnableProxy
Since: 2.26
getFamily
data SocketClientGetFamilyMethodInfo Source #
((~) * signature (m SocketFamily), MonadIO m, IsSocketClient a) => MethodInfo * SocketClientGetFamilyMethodInfo a signature Source # | |
socketClientGetFamily Source #
:: (HasCallStack, MonadIO m, IsSocketClient a) | |
=> a |
|
-> m SocketFamily | Returns: a |
getLocalAddress
data SocketClientGetLocalAddressMethodInfo Source #
((~) * signature (m SocketAddress), MonadIO m, IsSocketClient a) => MethodInfo * SocketClientGetLocalAddressMethodInfo a signature Source # | |
socketClientGetLocalAddress Source #
:: (HasCallStack, MonadIO m, IsSocketClient a) | |
=> a |
|
-> m SocketAddress | Returns: a |
getProtocol
data SocketClientGetProtocolMethodInfo Source #
((~) * signature (m SocketProtocol), MonadIO m, IsSocketClient a) => MethodInfo * SocketClientGetProtocolMethodInfo a signature Source # | |
socketClientGetProtocol Source #
:: (HasCallStack, MonadIO m, IsSocketClient a) | |
=> a |
|
-> m SocketProtocol | Returns: a |
Gets the protocol name type of the socket client.
See socketClientSetProtocol
for details.
Since: 2.22
getProxyResolver
data SocketClientGetProxyResolverMethodInfo Source #
((~) * signature (m ProxyResolver), MonadIO m, IsSocketClient a) => MethodInfo * SocketClientGetProxyResolverMethodInfo a signature Source # | |
socketClientGetProxyResolver Source #
:: (HasCallStack, MonadIO m, IsSocketClient a) | |
=> a |
|
-> m ProxyResolver | Returns: The |
Gets the ProxyResolver
being used by client
. Normally, this will
be the resolver returned by proxyResolverGetDefault
, but you
can override it with socketClientSetProxyResolver
.
Since: 2.36
getSocketType
data SocketClientGetSocketTypeMethodInfo Source #
((~) * signature (m SocketType), MonadIO m, IsSocketClient a) => MethodInfo * SocketClientGetSocketTypeMethodInfo a signature Source # | |
socketClientGetSocketType Source #
:: (HasCallStack, MonadIO m, IsSocketClient a) | |
=> a |
|
-> m SocketType | Returns: a |
getTimeout
data SocketClientGetTimeoutMethodInfo Source #
((~) * signature (m Word32), MonadIO m, IsSocketClient a) => MethodInfo * SocketClientGetTimeoutMethodInfo a signature Source # | |
socketClientGetTimeout Source #
:: (HasCallStack, MonadIO m, IsSocketClient a) | |
=> a |
|
-> m Word32 | Returns: the timeout in seconds |
Gets the I/O timeout time for sockets created by client
.
See socketClientSetTimeout
for details.
Since: 2.26
getTls
data SocketClientGetTlsMethodInfo Source #
((~) * signature (m Bool), MonadIO m, IsSocketClient a) => MethodInfo * SocketClientGetTlsMethodInfo a signature Source # | |
:: (HasCallStack, MonadIO m, IsSocketClient a) | |
=> a |
|
-> m Bool | Returns: whether |
Gets whether client
creates TLS connections. See
socketClientSetTls
for details.
Since: 2.28
getTlsValidationFlags
data SocketClientGetTlsValidationFlagsMethodInfo Source #
((~) * signature (m [TlsCertificateFlags]), MonadIO m, IsSocketClient a) => MethodInfo * SocketClientGetTlsValidationFlagsMethodInfo a signature Source # | |
socketClientGetTlsValidationFlags Source #
:: (HasCallStack, MonadIO m, IsSocketClient a) | |
=> a |
|
-> m [TlsCertificateFlags] | Returns: the TLS validation flags |
Gets the TLS validation flags used creating TLS connections via
client
.
Since: 2.28
new
:: (HasCallStack, MonadIO m) | |
=> m SocketClient | Returns: a |
Creates a new SocketClient
with the default options.
Since: 2.22
setEnableProxy
data SocketClientSetEnableProxyMethodInfo Source #
((~) * signature (Bool -> m ()), MonadIO m, IsSocketClient a) => MethodInfo * SocketClientSetEnableProxyMethodInfo a signature Source # | |
socketClientSetEnableProxy Source #
:: (HasCallStack, MonadIO m, IsSocketClient a) | |
=> a |
|
-> Bool |
|
-> m () |
Sets whether or not client
attempts to make connections via a
proxy server. When enabled (the default), SocketClient
will use a
ProxyResolver
to determine if a proxy protocol such as SOCKS is
needed, and automatically do the necessary proxy negotiation.
See also socketClientSetProxyResolver
.
Since: 2.26
setFamily
data SocketClientSetFamilyMethodInfo Source #
((~) * signature (SocketFamily -> m ()), MonadIO m, IsSocketClient a) => MethodInfo * SocketClientSetFamilyMethodInfo a signature Source # | |
socketClientSetFamily Source #
:: (HasCallStack, MonadIO m, IsSocketClient a) | |
=> a |
|
-> SocketFamily |
|
-> m () |
Sets the socket family of the socket client.
If this is set to something other than SocketFamilyInvalid
then the sockets created by this object will be of the specified
family.
This might be useful for instance if you want to force the local connection to be an ipv4 socket, even though the address might be an ipv6 mapped to ipv4 address.
Since: 2.22
setLocalAddress
data SocketClientSetLocalAddressMethodInfo Source #
((~) * signature (Maybe b -> m ()), MonadIO m, IsSocketClient a, IsSocketAddress b) => MethodInfo * SocketClientSetLocalAddressMethodInfo a signature Source # | |
socketClientSetLocalAddress Source #
:: (HasCallStack, MonadIO m, IsSocketClient a, IsSocketAddress b) | |
=> a |
|
-> Maybe b |
|
-> m () |
Sets the local address of the socket client.
The sockets created by this object will bound to the
specified address (if not Nothing
) before connecting.
This is useful if you want to ensure that the local side of the connection is on a specific port, or on a specific interface.
Since: 2.22
setProtocol
data SocketClientSetProtocolMethodInfo Source #
((~) * signature (SocketProtocol -> m ()), MonadIO m, IsSocketClient a) => MethodInfo * SocketClientSetProtocolMethodInfo a signature Source # | |
socketClientSetProtocol Source #
:: (HasCallStack, MonadIO m, IsSocketClient a) | |
=> a |
|
-> SocketProtocol |
|
-> m () |
Sets the protocol of the socket client. The sockets created by this object will use of the specified protocol.
If protocol
is 0
that means to use the default
protocol for the socket family and type.
Since: 2.22
setProxyResolver
data SocketClientSetProxyResolverMethodInfo Source #
((~) * signature (Maybe b -> m ()), MonadIO m, IsSocketClient a, IsProxyResolver b) => MethodInfo * SocketClientSetProxyResolverMethodInfo a signature Source # | |
socketClientSetProxyResolver Source #
:: (HasCallStack, MonadIO m, IsSocketClient a, IsProxyResolver b) | |
=> a |
|
-> Maybe b |
|
-> m () |
Overrides the ProxyResolver
used by client
. You can call this if
you want to use specific proxies, rather than using the system
default proxy settings.
Note that whether or not the proxy resolver is actually used
depends on the setting of SocketClient
:enable-proxy
, which is not
changed by this function (but which is True
by default)
Since: 2.36
setSocketType
data SocketClientSetSocketTypeMethodInfo Source #
((~) * signature (SocketType -> m ()), MonadIO m, IsSocketClient a) => MethodInfo * SocketClientSetSocketTypeMethodInfo a signature Source # | |
socketClientSetSocketType Source #
:: (HasCallStack, MonadIO m, IsSocketClient a) | |
=> a |
|
-> SocketType |
|
-> m () |
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 SocketTypeDatagram
,
as GSocketClient is used for connection oriented services.
Since: 2.22
setTimeout
data SocketClientSetTimeoutMethodInfo Source #
((~) * signature (Word32 -> m ()), MonadIO m, IsSocketClient a) => MethodInfo * SocketClientSetTimeoutMethodInfo a signature Source # | |
socketClientSetTimeout Source #
:: (HasCallStack, MonadIO m, IsSocketClient a) | |
=> a |
|
-> Word32 |
|
-> m () |
Sets the I/O timeout for sockets created by client
. timeout
is a
time in seconds, or 0 for no timeout (the default).
The timeout value affects the initial connection attempt as well,
so setting this may cause calls to socketClientConnect
, etc,
to fail with IOErrorEnumTimedOut
.
Since: 2.26
setTls
data SocketClientSetTlsMethodInfo Source #
((~) * signature (Bool -> m ()), MonadIO m, IsSocketClient a) => MethodInfo * SocketClientSetTlsMethodInfo a signature Source # | |
:: (HasCallStack, MonadIO m, IsSocketClient a) | |
=> a |
|
-> Bool |
|
-> m () |
Sets whether client
creates TLS (aka SSL) connections. If tls
is
True
, client
will wrap its connections in a TlsClientConnection
and perform a TLS handshake when connecting.
Note that since SocketClient
must return a SocketConnection
,
but TlsClientConnection
is not a SocketConnection
, this
actually wraps the resulting TlsClientConnection
in a
TcpWrapperConnection
when returning it. You can use
tcpWrapperConnectionGetBaseIoStream
on the return value
to extract the TlsClientConnection
.
If you need to modify the behavior of the TLS handshake (eg, by
setting a client-side certificate to use, or connecting to the
TlsConnection
::accept-certificate
signal), you can connect to
client
's SocketClient
::event
signal and wait for it to be
emitted with SocketClientEventTlsHandshaking
, which will give you
a chance to see the TlsClientConnection
before the handshake
starts.
Since: 2.28
setTlsValidationFlags
data SocketClientSetTlsValidationFlagsMethodInfo Source #
((~) * signature ([TlsCertificateFlags] -> m ()), MonadIO m, IsSocketClient a) => MethodInfo * SocketClientSetTlsValidationFlagsMethodInfo a signature Source # | |
socketClientSetTlsValidationFlags Source #
:: (HasCallStack, MonadIO m, IsSocketClient a) | |
=> a |
|
-> [TlsCertificateFlags] |
|
-> m () |
Sets the TLS validation flags used when creating TLS connections
via client
. The default value is TlsCertificateFlagsValidateAll
.
Since: 2.28
Properties
enableProxy
data SocketClientEnableProxyPropertyInfo Source #
constructSocketClientEnableProxy :: IsSocketClient o => Bool -> IO (GValueConstruct o) Source #
getSocketClientEnableProxy :: (MonadIO m, IsSocketClient o) => o -> m Bool Source #
setSocketClientEnableProxy :: (MonadIO m, IsSocketClient o) => o -> Bool -> m () Source #
socketClientEnableProxy :: AttrLabelProxy "enableProxy" Source #
family
data SocketClientFamilyPropertyInfo Source #
constructSocketClientFamily :: IsSocketClient o => SocketFamily -> IO (GValueConstruct o) Source #
getSocketClientFamily :: (MonadIO m, IsSocketClient o) => o -> m SocketFamily Source #
setSocketClientFamily :: (MonadIO m, IsSocketClient o) => o -> SocketFamily -> m () Source #
socketClientFamily :: AttrLabelProxy "family" Source #
localAddress
data SocketClientLocalAddressPropertyInfo Source #
clearSocketClientLocalAddress :: (MonadIO m, IsSocketClient o) => o -> m () Source #
constructSocketClientLocalAddress :: (IsSocketClient o, IsSocketAddress a) => a -> IO (GValueConstruct o) Source #
getSocketClientLocalAddress :: (MonadIO m, IsSocketClient o) => o -> m SocketAddress Source #
setSocketClientLocalAddress :: (MonadIO m, IsSocketClient o, IsSocketAddress a) => o -> a -> m () Source #
socketClientLocalAddress :: AttrLabelProxy "localAddress" Source #
protocol
data SocketClientProtocolPropertyInfo Source #
constructSocketClientProtocol :: IsSocketClient o => SocketProtocol -> IO (GValueConstruct o) Source #
getSocketClientProtocol :: (MonadIO m, IsSocketClient o) => o -> m SocketProtocol Source #
setSocketClientProtocol :: (MonadIO m, IsSocketClient o) => o -> SocketProtocol -> m () Source #
socketClientProtocol :: AttrLabelProxy "protocol" Source #
proxyResolver
data SocketClientProxyResolverPropertyInfo Source #
clearSocketClientProxyResolver :: (MonadIO m, IsSocketClient o) => o -> m () Source #
constructSocketClientProxyResolver :: (IsSocketClient o, IsProxyResolver a) => a -> IO (GValueConstruct o) Source #
getSocketClientProxyResolver :: (MonadIO m, IsSocketClient o) => o -> m ProxyResolver Source #
setSocketClientProxyResolver :: (MonadIO m, IsSocketClient o, IsProxyResolver a) => o -> a -> m () Source #
socketClientProxyResolver :: AttrLabelProxy "proxyResolver" Source #
timeout
data SocketClientTimeoutPropertyInfo Source #
constructSocketClientTimeout :: IsSocketClient o => Word32 -> IO (GValueConstruct o) Source #
getSocketClientTimeout :: (MonadIO m, IsSocketClient o) => o -> m Word32 Source #
setSocketClientTimeout :: (MonadIO m, IsSocketClient o) => o -> Word32 -> m () Source #
socketClientTimeout :: AttrLabelProxy "timeout" Source #
tls
data SocketClientTlsPropertyInfo Source #
constructSocketClientTls :: IsSocketClient o => Bool -> IO (GValueConstruct o) Source #
getSocketClientTls :: (MonadIO m, IsSocketClient o) => o -> m Bool Source #
setSocketClientTls :: (MonadIO m, IsSocketClient o) => o -> Bool -> m () Source #
socketClientTls :: AttrLabelProxy "tls" Source #
tlsValidationFlags
data SocketClientTlsValidationFlagsPropertyInfo Source #
constructSocketClientTlsValidationFlags :: IsSocketClient o => [TlsCertificateFlags] -> IO (GValueConstruct o) Source #
getSocketClientTlsValidationFlags :: (MonadIO m, IsSocketClient o) => o -> m [TlsCertificateFlags] Source #
setSocketClientTlsValidationFlags :: (MonadIO m, IsSocketClient o) => o -> [TlsCertificateFlags] -> m () Source #
socketClientTlsValidationFlags :: AttrLabelProxy "tlsValidationFlags" Source #
type
data SocketClientTypePropertyInfo Source #
constructSocketClientType :: IsSocketClient o => SocketType -> IO (GValueConstruct o) Source #
getSocketClientType :: (MonadIO m, IsSocketClient o) => o -> m SocketType Source #
setSocketClientType :: (MonadIO m, IsSocketClient o) => o -> SocketType -> m () Source #
socketClientType :: AttrLabelProxy "type" Source #
Signals
event
type C_SocketClientEventCallback = Ptr () -> CUInt -> Ptr SocketConnectable -> Ptr IOStream -> Ptr () -> IO () Source #
type SocketClientEventCallback = SocketClientEvent -> SocketConnectable -> Maybe IOStream -> IO () Source #
afterSocketClientEvent :: (IsSocketClient a, MonadIO m) => a -> SocketClientEventCallback -> m SignalHandlerId Source #
mk_SocketClientEventCallback :: C_SocketClientEventCallback -> IO (FunPtr C_SocketClientEventCallback) Source #
onSocketClientEvent :: (IsSocketClient a, MonadIO m) => a -> SocketClientEventCallback -> m SignalHandlerId Source #
wrap_SocketClientEventCallback :: SocketClientEventCallback -> Ptr () -> CUInt -> Ptr SocketConnectable -> Ptr IOStream -> Ptr () -> IO () Source #