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 |
SocketConnection
is a IOStream
for a connected socket. They
can be created either by SocketClient
when connecting to a host,
or by SocketListener
when accepting a new client.
The type of the SocketConnection
object returned from these calls
depends on the type of the underlying socket that is in use. For
instance, for a TCP/IP connection it will be a TcpConnection
.
Choosing what type of object to construct is done with the socket
connection factory, and it is possible for 3rd parties to register
custom socket connection types for specific combination of socket
family/type/protocol using socketConnectionFactoryRegisterType
.
To close a SocketConnection
, use iOStreamClose
. Closing both
substreams of the IOStream
separately will not close the underlying
Socket
.
Since: 2.22
Synopsis
- newtype SocketConnection = SocketConnection (ManagedPtr SocketConnection)
- class GObject o => IsSocketConnection o
- toSocketConnection :: (MonadIO m, IsSocketConnection o) => o -> m SocketConnection
- noSocketConnection :: Maybe SocketConnection
- socketConnectionConnect :: (HasCallStack, MonadIO m, IsSocketConnection a, IsSocketAddress b, IsCancellable c) => a -> b -> Maybe c -> m ()
- socketConnectionConnectAsync :: (HasCallStack, MonadIO m, IsSocketConnection a, IsSocketAddress b, IsCancellable c) => a -> b -> Maybe c -> Maybe AsyncReadyCallback -> m ()
- socketConnectionConnectFinish :: (HasCallStack, MonadIO m, IsSocketConnection a, IsAsyncResult b) => a -> b -> m ()
- socketConnectionFactoryLookupType :: (HasCallStack, MonadIO m) => SocketFamily -> SocketType -> Int32 -> m GType
- socketConnectionFactoryRegisterType :: (HasCallStack, MonadIO m) => GType -> SocketFamily -> SocketType -> Int32 -> m ()
- socketConnectionGetLocalAddress :: (HasCallStack, MonadIO m, IsSocketConnection a) => a -> m SocketAddress
- socketConnectionGetRemoteAddress :: (HasCallStack, MonadIO m, IsSocketConnection a) => a -> m SocketAddress
- socketConnectionGetSocket :: (HasCallStack, MonadIO m, IsSocketConnection a) => a -> m Socket
- socketConnectionIsConnected :: (HasCallStack, MonadIO m, IsSocketConnection a) => a -> m Bool
- constructSocketConnectionSocket :: (IsSocketConnection o, IsSocket a) => a -> IO (GValueConstruct o)
- getSocketConnectionSocket :: (MonadIO m, IsSocketConnection o) => o -> m Socket
Exported types
newtype SocketConnection Source #
Memory-managed wrapper type.
Instances
GObject SocketConnection Source # | |
Defined in GI.Gio.Objects.SocketConnection gobjectType :: SocketConnection -> IO GType # | |
IsObject SocketConnection Source # | |
Defined in GI.Gio.Objects.SocketConnection | |
IsIOStream SocketConnection Source # | |
Defined in GI.Gio.Objects.SocketConnection | |
IsSocketConnection SocketConnection Source # | |
Defined in GI.Gio.Objects.SocketConnection |
class GObject o => IsSocketConnection o Source #
Type class for types which can be safely cast to SocketConnection
, for instance with toSocketConnection
.
Instances
(GObject a, (UnknownAncestorError SocketConnection a :: Constraint)) => IsSocketConnection a Source # | |
Defined in GI.Gio.Objects.SocketConnection | |
IsSocketConnection SocketConnection Source # | |
Defined in GI.Gio.Objects.SocketConnection | |
IsSocketConnection TcpConnection Source # | |
Defined in GI.Gio.Objects.TcpConnection | |
IsSocketConnection TcpWrapperConnection Source # | |
Defined in GI.Gio.Objects.TcpWrapperConnection | |
IsSocketConnection UnixConnection Source # | |
Defined in GI.Gio.Objects.UnixConnection |
toSocketConnection :: (MonadIO m, IsSocketConnection o) => o -> m SocketConnection Source #
Cast to SocketConnection
, for types for which this is known to be safe. For general casts, use castTo
.
noSocketConnection :: Maybe SocketConnection Source #
A convenience alias for Nothing
:: Maybe
SocketConnection
.
Methods
connect
socketConnectionConnect Source #
:: (HasCallStack, MonadIO m, IsSocketConnection a, IsSocketAddress b, IsCancellable c) | |
=> a |
|
-> b |
|
-> Maybe c |
|
-> m () | (Can throw |
Connect connection
to the specified remote address.
Since: 2.32
connectAsync
socketConnectionConnectAsync Source #
:: (HasCallStack, MonadIO m, IsSocketConnection a, IsSocketAddress b, IsCancellable c) | |
=> a |
|
-> b |
|
-> Maybe c |
|
-> Maybe AsyncReadyCallback |
|
-> m () |
Asynchronously connect connection
to the specified remote address.
This clears the Socket
:blocking
flag on connection
's underlying
socket if it is currently set.
Use socketConnectionConnectFinish
to retrieve the result.
Since: 2.32
connectFinish
socketConnectionConnectFinish Source #
:: (HasCallStack, MonadIO m, IsSocketConnection a, IsAsyncResult b) | |
=> a |
|
-> b |
|
-> m () | (Can throw |
Gets the result of a socketConnectionConnectAsync
call.
Since: 2.32
factoryLookupType
socketConnectionFactoryLookupType Source #
:: (HasCallStack, MonadIO m) | |
=> SocketFamily |
|
-> SocketType |
|
-> Int32 |
|
-> m GType | Returns: a |
Looks up the GType
to be used when creating socket connections on
sockets with the specified family
, type
and protocolId
.
If no type is registered, the SocketConnection
base type is returned.
Since: 2.22
factoryRegisterType
socketConnectionFactoryRegisterType Source #
:: (HasCallStack, MonadIO m) | |
=> GType |
|
-> SocketFamily |
|
-> SocketType |
|
-> Int32 |
|
-> m () |
Looks up the GType
to be used when creating socket connections on
sockets with the specified family
, type
and protocol
.
If no type is registered, the SocketConnection
base type is returned.
Since: 2.22
getLocalAddress
socketConnectionGetLocalAddress Source #
:: (HasCallStack, MonadIO m, IsSocketConnection a) | |
=> a |
|
-> m SocketAddress | Returns: a |
Try to get the local address of a socket connection.
Since: 2.22
getRemoteAddress
socketConnectionGetRemoteAddress Source #
:: (HasCallStack, MonadIO m, IsSocketConnection a) | |
=> a |
|
-> m SocketAddress | Returns: a |
Try to get the remote address of a socket connection.
Since GLib 2.40, when used with socketClientConnect
or
socketClientConnectAsync
, during emission of
SocketClientEventConnecting
, this function will return the remote
address that will be used for the connection. This allows
applications to print e.g. "Connecting to example.com
(10.42.77.3)...".
Since: 2.22
getSocket
socketConnectionGetSocket Source #
:: (HasCallStack, MonadIO m, IsSocketConnection a) | |
=> a |
|
-> m Socket |
Gets the underlying Socket
object of the connection.
This can be useful if you want to do something unusual on it
not supported by the SocketConnection
APIs.
Since: 2.22
isConnected
socketConnectionIsConnected Source #
:: (HasCallStack, MonadIO m, IsSocketConnection a) | |
=> a |
|
-> m Bool | Returns: whether |
Checks if connection
is connected. This is equivalent to calling
socketIsConnected
on connection
's underlying Socket
.
Since: 2.32
Properties
socket
No description available in the introspection data.
constructSocketConnectionSocket :: (IsSocketConnection o, IsSocket a) => a -> IO (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “socket
” property. This is rarely needed directly, but it is used by new
.
getSocketConnectionSocket :: (MonadIO m, IsSocketConnection o) => o -> m Socket Source #
Get the value of the “socket
” property.
When overloading is enabled, this is equivalent to
get
socketConnection #socket