| 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 |
GI.Gio.Objects.SocketConnection
Contents
Description
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.
- 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 #
Constructors
| SocketConnection (ManagedPtr SocketConnection) |
class GObject o => IsSocketConnection o Source #
toSocketConnection :: (MonadIO m, IsSocketConnection o) => o -> m SocketConnection Source #
Methods
connect
socketConnectionConnect Source #
Arguments
| :: (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 #
Arguments
| :: (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 #
Arguments
| :: (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 #
Arguments
| :: (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 #
Arguments
| :: (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 #
Arguments
| :: (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 #
Arguments
| :: (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 #
Arguments
| :: (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 #
Arguments
| :: (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
constructSocketConnectionSocket :: (IsSocketConnection o, IsSocket a) => a -> IO (GValueConstruct o) Source #
getSocketConnectionSocket :: (MonadIO m, IsSocketConnection o) => o -> m Socket Source #