gi-gio-2.0.18: Gio bindings

CopyrightWill Thompson Iñaki García Etxebarria and Jonas Platte
LicenseLGPL-2.1
MaintainerIñaki García Etxebarria (garetxe@gmail.com)
Safe HaskellNone
LanguageHaskell2010

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.

Since: 2.22

Synopsis

Exported types

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.

Methods

connect

socketConnectionConnect Source #

Arguments

:: (HasCallStack, MonadIO m, IsSocketConnection a, IsSocketAddress b, IsCancellable c) 
=> a

connection: a SocketConnection

-> b

address: a SocketAddress specifying the remote address.

-> Maybe c

cancellable: a GCancellable or Nothing

-> m ()

(Can throw GError)

Connect connection to the specified remote address.

Since: 2.32

connectAsync

socketConnectionConnectAsync Source #

Arguments

:: (HasCallStack, MonadIO m, IsSocketConnection a, IsSocketAddress b, IsCancellable c) 
=> a

connection: a SocketConnection

-> b

address: a SocketAddress specifying the remote address.

-> Maybe c

cancellable: a GCancellable or Nothing

-> Maybe AsyncReadyCallback

callback: a 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

connection: a SocketConnection

-> b

result: the AsyncResult

-> m ()

(Can throw GError)

Gets the result of a socketConnectionConnectAsync call.

Since: 2.32

factoryLookupType

socketConnectionFactoryLookupType Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> SocketFamily

family: a SocketFamily

-> SocketType

type: a SocketType

-> Int32

protocolId: a protocol id

-> m GType

Returns: a GType

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

gType: a GType, inheriting from G_TYPE_SOCKET_CONNECTION

-> SocketFamily

family: a SocketFamily

-> SocketType

type: a SocketType

-> Int32

protocol: a protocol id

-> 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

connection: a SocketConnection

-> m SocketAddress

Returns: a SocketAddress or Nothing on error. Free the returned object with objectUnref. (Can throw GError)

Try to get the local address of a socket connection.

Since: 2.22

getRemoteAddress

socketConnectionGetRemoteAddress Source #

Arguments

:: (HasCallStack, MonadIO m, IsSocketConnection a) 
=> a

connection: a SocketConnection

-> m SocketAddress

Returns: a SocketAddress or Nothing on error. Free the returned object with objectUnref. (Can throw GError)

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

connection: a SocketConnection

-> m Socket

Returns: a Socket or Nothing on error.

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

connection: a SocketConnection

-> m Bool

Returns: whether connection is connected

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