Copyright | Will Thompson Iñaki García Etxebarria and Jonas Platte |
---|---|
License | LGPL-2.1 |
Maintainer | Iñaki García Etxebarria (inaki@blueleaf.cc) |
Safe Haskell | None |
Language | Haskell2010 |
No description available in the introspection data.
Synopsis
- newtype Socket = Socket (ManagedPtr Socket)
- class (GObject o, IsDescendantOf Socket o) => IsSocket o
- toSocket :: (MonadIO m, IsSocket o) => o -> m Socket
- noSocket :: Maybe Socket
- socketConnectAsync :: (HasCallStack, MonadIO m, IsSocket a, IsCancellable b) => a -> Maybe b -> SocketCallback -> m ()
- socketConnectSync :: (HasCallStack, MonadIO m, IsSocket a, IsCancellable b) => a -> Maybe b -> m Word32
- socketDisconnect :: (HasCallStack, MonadIO m, IsSocket a) => a -> m ()
- socketGetFd :: (HasCallStack, MonadIO m, IsSocket a) => a -> m Int32
- socketGetLocalAddress :: (HasCallStack, MonadIO m, IsSocket a) => a -> m Address
- socketGetRemoteAddress :: (HasCallStack, MonadIO m, IsSocket a) => a -> m Address
- socketIsConnected :: (HasCallStack, MonadIO m, IsSocket a) => a -> m Bool
- socketIsSsl :: (HasCallStack, MonadIO m, IsSocket a) => a -> m Bool
- socketListen :: (HasCallStack, MonadIO m, IsSocket a) => a -> m Bool
- socketRead :: (HasCallStack, MonadIO m, IsSocket a, IsCancellable b) => a -> ByteString -> Maybe b -> m (SocketIOStatus, Word64)
- socketReadUntil :: (HasCallStack, MonadIO m, IsSocket a, IsCancellable b) => a -> ByteString -> Ptr () -> Word64 -> Bool -> Maybe b -> m (SocketIOStatus, Word64)
- socketStartProxySsl :: (HasCallStack, MonadIO m, IsSocket a, IsCancellable b) => a -> Text -> Maybe b -> m Bool
- socketStartSsl :: (HasCallStack, MonadIO m, IsSocket a, IsCancellable b) => a -> Maybe b -> m Bool
- socketWrite :: (HasCallStack, MonadIO m, IsSocket a, IsCancellable b) => a -> ByteString -> Maybe b -> m (SocketIOStatus, Word64)
- constructSocketAsyncContext :: IsSocket o => Ptr () -> IO (GValueConstruct o)
- getSocketAsyncContext :: (MonadIO m, IsSocket o) => o -> m (Ptr ())
- constructSocketFd :: IsSocket o => Int32 -> IO (GValueConstruct o)
- getSocketFd :: (MonadIO m, IsSocket o) => o -> m Int32
- constructSocketGsocket :: (IsSocket o, IsSocket a) => a -> IO (GValueConstruct o)
- constructSocketIostream :: (IsSocket o, IsIOStream a) => a -> IO (GValueConstruct o)
- constructSocketIpv6Only :: IsSocket o => Bool -> IO (GValueConstruct o)
- getSocketIpv6Only :: (MonadIO m, IsSocket o) => o -> m Bool
- setSocketIpv6Only :: (MonadIO m, IsSocket o) => o -> Bool -> m ()
- getSocketIsServer :: (MonadIO m, IsSocket o) => o -> m Bool
- constructSocketLocalAddress :: (IsSocket o, IsAddress a) => a -> IO (GValueConstruct o)
- getSocketLocalAddress :: (MonadIO m, IsSocket o) => o -> m Address
- constructSocketNonBlocking :: IsSocket o => Bool -> IO (GValueConstruct o)
- getSocketNonBlocking :: (MonadIO m, IsSocket o) => o -> m Bool
- setSocketNonBlocking :: (MonadIO m, IsSocket o) => o -> Bool -> m ()
- constructSocketRemoteAddress :: (IsSocket o, IsAddress a) => a -> IO (GValueConstruct o)
- getSocketRemoteAddress :: (MonadIO m, IsSocket o) => o -> m Address
- constructSocketSslCreds :: IsSocket o => Ptr () -> IO (GValueConstruct o)
- getSocketSslCreds :: (MonadIO m, IsSocket o) => o -> m (Ptr ())
- setSocketSslCreds :: (MonadIO m, IsSocket o) => o -> Ptr () -> m ()
- constructSocketSslFallback :: IsSocket o => Bool -> IO (GValueConstruct o)
- getSocketSslFallback :: (MonadIO m, IsSocket o) => o -> m Bool
- constructSocketSslStrict :: IsSocket o => Bool -> IO (GValueConstruct o)
- getSocketSslStrict :: (MonadIO m, IsSocket o) => o -> m Bool
- constructSocketTimeout :: IsSocket o => Word32 -> IO (GValueConstruct o)
- getSocketTimeout :: (MonadIO m, IsSocket o) => o -> m Word32
- setSocketTimeout :: (MonadIO m, IsSocket o) => o -> Word32 -> m ()
- getSocketTlsCertificate :: (MonadIO m, IsSocket o) => o -> m (Maybe TlsCertificate)
- getSocketTlsErrors :: (MonadIO m, IsSocket o) => o -> m [TlsCertificateFlags]
- getSocketTrustedCertificate :: (MonadIO m, IsSocket o) => o -> m Bool
- constructSocketUseThreadContext :: IsSocket o => Bool -> IO (GValueConstruct o)
- getSocketUseThreadContext :: (MonadIO m, IsSocket o) => o -> m Bool
- type C_SocketDisconnectedCallback = Ptr () -> Ptr () -> IO ()
- type SocketDisconnectedCallback = IO ()
- afterSocketDisconnected :: (IsSocket a, MonadIO m) => a -> SocketDisconnectedCallback -> m SignalHandlerId
- genClosure_SocketDisconnected :: MonadIO m => SocketDisconnectedCallback -> m (GClosure C_SocketDisconnectedCallback)
- mk_SocketDisconnectedCallback :: C_SocketDisconnectedCallback -> IO (FunPtr C_SocketDisconnectedCallback)
- noSocketDisconnectedCallback :: Maybe SocketDisconnectedCallback
- onSocketDisconnected :: (IsSocket a, MonadIO m) => a -> SocketDisconnectedCallback -> m SignalHandlerId
- wrap_SocketDisconnectedCallback :: SocketDisconnectedCallback -> C_SocketDisconnectedCallback
- type C_SocketEventCallback = Ptr () -> CUInt -> Ptr IOStream -> Ptr () -> IO ()
- type SocketEventCallback = SocketClientEvent -> IOStream -> IO ()
- afterSocketEvent :: (IsSocket a, MonadIO m) => a -> SocketEventCallback -> m SignalHandlerId
- genClosure_SocketEvent :: MonadIO m => SocketEventCallback -> m (GClosure C_SocketEventCallback)
- mk_SocketEventCallback :: C_SocketEventCallback -> IO (FunPtr C_SocketEventCallback)
- noSocketEventCallback :: Maybe SocketEventCallback
- onSocketEvent :: (IsSocket a, MonadIO m) => a -> SocketEventCallback -> m SignalHandlerId
- wrap_SocketEventCallback :: SocketEventCallback -> C_SocketEventCallback
- type C_SocketNewConnectionCallback = Ptr () -> Ptr Socket -> Ptr () -> IO ()
- type SocketNewConnectionCallback = Socket -> IO ()
- afterSocketNewConnection :: (IsSocket a, MonadIO m) => a -> SocketNewConnectionCallback -> m SignalHandlerId
- genClosure_SocketNewConnection :: MonadIO m => SocketNewConnectionCallback -> m (GClosure C_SocketNewConnectionCallback)
- mk_SocketNewConnectionCallback :: C_SocketNewConnectionCallback -> IO (FunPtr C_SocketNewConnectionCallback)
- noSocketNewConnectionCallback :: Maybe SocketNewConnectionCallback
- onSocketNewConnection :: (IsSocket a, MonadIO m) => a -> SocketNewConnectionCallback -> m SignalHandlerId
- wrap_SocketNewConnectionCallback :: SocketNewConnectionCallback -> C_SocketNewConnectionCallback
- type C_SocketReadableCallback = Ptr () -> Ptr () -> IO ()
- type SocketReadableCallback = IO ()
- afterSocketReadable :: (IsSocket a, MonadIO m) => a -> SocketReadableCallback -> m SignalHandlerId
- genClosure_SocketReadable :: MonadIO m => SocketReadableCallback -> m (GClosure C_SocketReadableCallback)
- mk_SocketReadableCallback :: C_SocketReadableCallback -> IO (FunPtr C_SocketReadableCallback)
- noSocketReadableCallback :: Maybe SocketReadableCallback
- onSocketReadable :: (IsSocket a, MonadIO m) => a -> SocketReadableCallback -> m SignalHandlerId
- wrap_SocketReadableCallback :: SocketReadableCallback -> C_SocketReadableCallback
- type C_SocketWritableCallback = Ptr () -> Ptr () -> IO ()
- type SocketWritableCallback = IO ()
- afterSocketWritable :: (IsSocket a, MonadIO m) => a -> SocketWritableCallback -> m SignalHandlerId
- genClosure_SocketWritable :: MonadIO m => SocketWritableCallback -> m (GClosure C_SocketWritableCallback)
- mk_SocketWritableCallback :: C_SocketWritableCallback -> IO (FunPtr C_SocketWritableCallback)
- noSocketWritableCallback :: Maybe SocketWritableCallback
- onSocketWritable :: (IsSocket a, MonadIO m) => a -> SocketWritableCallback -> m SignalHandlerId
- wrap_SocketWritableCallback :: SocketWritableCallback -> C_SocketWritableCallback
Exported types
Memory-managed wrapper type.
Instances
GObject Socket Source # | |
Defined in GI.Soup.Objects.Socket gobjectType :: IO GType # | |
HasParentTypes Socket Source # | |
Defined in GI.Soup.Objects.Socket | |
type ParentTypes Socket Source # | |
Defined in GI.Soup.Objects.Socket |
class (GObject o, IsDescendantOf Socket o) => IsSocket o Source #
Instances
(GObject o, IsDescendantOf Socket o) => IsSocket o Source # | |
Defined in GI.Soup.Objects.Socket |
Methods
connectAsync
:: (HasCallStack, MonadIO m, IsSocket a, IsCancellable b) | |
=> a |
|
-> Maybe b |
|
-> SocketCallback |
|
-> m () |
Begins asynchronously connecting to sock
's remote address. The
socket will call callback
when it succeeds or fails (but not
before returning from this function).
If cancellable
is non-Nothing
, it can be used to cancel the
connection. callback
will still be invoked in this case, with a
status of StatusCancelled
.
connectSync
:: (HasCallStack, MonadIO m, IsSocket a, IsCancellable b) | |
=> a |
|
-> Maybe b |
|
-> m Word32 | Returns: a success or failure code. |
Attempt to synchronously connect sock
to its remote address.
If cancellable
is non-Nothing
, it can be used to cancel the
connection, in which case socketConnectSync
will return
StatusCancelled
.
disconnect
:: (HasCallStack, MonadIO m, IsSocket a) | |
=> a |
|
-> m () |
Disconnects sock
. Any further read or write attempts on it will
fail.
getFd
:: (HasCallStack, MonadIO m, IsSocket a) | |
=> a |
|
-> m Int32 | Returns: |
Gets sock
's underlying file descriptor.
Note that fiddling with the file descriptor may break the
Socket
.
getLocalAddress
socketGetLocalAddress Source #
Returns the Address
corresponding to the local end of sock
.
Calling this method on an unconnected socket is considered to be an error, and produces undefined results.
getRemoteAddress
socketGetRemoteAddress Source #
Returns the Address
corresponding to the remote end of sock
.
Calling this method on an unconnected socket is considered to be an error, and produces undefined results.
isConnected
Tests if sock
is connected to another host
isSsl
:: (HasCallStack, MonadIO m, IsSocket a) | |
=> a |
|
-> m Bool | Returns: |
Tests if sock
is doing (or has attempted to do) SSL.
listen
:: (HasCallStack, MonadIO m, IsSocket a) | |
=> a |
|
-> m Bool | Returns: whether or not |
Makes sock
start listening on its local address. When connections
come in, sock
will emit Socket
::new_connection
.
read
:: (HasCallStack, MonadIO m, IsSocket a, IsCancellable b) | |
=> a |
|
-> ByteString |
|
-> Maybe b |
|
-> m (SocketIOStatus, Word64) | Returns: a |
Attempts to read up to len
bytes from sock
into buffer
. If some
data is successfully read, socketRead
will return
SocketIOStatusOk
, and *nread
will contain the number of bytes
actually read (which may be less than len
).
If sock
is non-blocking, and no data is available, the return
value will be SocketIOStatusWouldBlock
. In this case, the caller
can connect to the Socket
::readable
signal to know when there
is more data to read. (NB: You MUST read all available data off the
socket first. Socket
::readable
is only emitted after
socketRead
returns SocketIOStatusWouldBlock
, and it is only
emitted once. See the documentation for Socket
:non-blocking
.)
readUntil
:: (HasCallStack, MonadIO m, IsSocket a, IsCancellable b) | |
=> a |
|
-> ByteString |
|
-> Ptr () |
|
-> Word64 |
|
-> Bool |
|
-> Maybe b |
|
-> m (SocketIOStatus, Word64) | Returns: as for |
Like socketRead
, but reads no further than the first
occurrence of boundary
. (If the boundary is found, it will be
included in the returned data, and *gotBoundary
will be set to
True
.) Any data after the boundary will returned in future reads.
socketReadUntil
will almost always return fewer than len
bytes: if the boundary is found, then it will only return the bytes
up until the end of the boundary, and if the boundary is not found,
then it will leave the last <literal>(boundary_len - 1)</literal>
bytes in its internal buffer, in case they form the start of the
boundary string. Thus, len
normally needs to be at least 1 byte
longer than boundaryLen
if you want to make any progress at all.
startProxySsl
:: (HasCallStack, MonadIO m, IsSocket a, IsCancellable b) | |
=> a |
|
-> Text |
|
-> Maybe b |
|
-> m Bool | Returns: success or failure |
Starts using SSL on socket
, expecting to find a host named
sslHost
.
startSsl
:: (HasCallStack, MonadIO m, IsSocket a, IsCancellable b) | |
=> a |
|
-> Maybe b |
|
-> m Bool | Returns: success or failure |
Starts using SSL on socket
.
write
:: (HasCallStack, MonadIO m, IsSocket a, IsCancellable b) | |
=> a |
|
-> ByteString |
|
-> Maybe b |
|
-> m (SocketIOStatus, Word64) | Returns: a |
Attempts to write len
bytes from buffer
to sock
. If some data is
successfully written, the return status will be SocketIOStatusOk
,
and *nwrote
will contain the number of bytes actually written
(which may be less than len
).
If sock
is non-blocking, and no data could be written right away,
the return value will be SocketIOStatusWouldBlock
. In this case,
the caller can connect to the Socket
::writable
signal to know
when more data can be written. (NB: Socket
::writable
is only
emitted after socketWrite
returns SocketIOStatusWouldBlock
,
and it is only emitted once. See the documentation for
Socket
:non-blocking
.)
Properties
asyncContext
No description available in the introspection data.
constructSocketAsyncContext :: IsSocket o => Ptr () -> IO (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “async-context
” property. This is rarely needed directly, but it is used by new
.
getSocketAsyncContext :: (MonadIO m, IsSocket o) => o -> m (Ptr ()) Source #
Get the value of the “async-context
” property.
When overloading is enabled, this is equivalent to
get
socket #asyncContext
fd
No description available in the introspection data.
constructSocketFd :: IsSocket o => Int32 -> IO (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “fd
” property. This is rarely needed directly, but it is used by new
.
getSocketFd :: (MonadIO m, IsSocket o) => o -> m Int32 Source #
Get the value of the “fd
” property.
When overloading is enabled, this is equivalent to
get
socket #fd
gsocket
No description available in the introspection data.
constructSocketGsocket :: (IsSocket o, IsSocket a) => a -> IO (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “gsocket
” property. This is rarely needed directly, but it is used by new
.
iostream
No description available in the introspection data.
constructSocketIostream :: (IsSocket o, IsIOStream a) => a -> IO (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “iostream
” property. This is rarely needed directly, but it is used by new
.
ipv6Only
No description available in the introspection data.
constructSocketIpv6Only :: IsSocket o => Bool -> IO (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “ipv6-only
” property. This is rarely needed directly, but it is used by new
.
getSocketIpv6Only :: (MonadIO m, IsSocket o) => o -> m Bool Source #
Get the value of the “ipv6-only
” property.
When overloading is enabled, this is equivalent to
get
socket #ipv6Only
setSocketIpv6Only :: (MonadIO m, IsSocket o) => o -> Bool -> m () Source #
Set the value of the “ipv6-only
” property.
When overloading is enabled, this is equivalent to
set
socket [ #ipv6Only:=
value ]
isServer
Whether or not the socket is a server socket.
Note that for "ordinary" SoupSockets
this will be set for
both listening sockets and the sockets emitted by
Socket
::new-connection
, but for sockets created by
setting Socket
:fd
, it will only be set for listening
sockets.
getSocketIsServer :: (MonadIO m, IsSocket o) => o -> m Bool Source #
Get the value of the “is-server
” property.
When overloading is enabled, this is equivalent to
get
socket #isServer
localAddress
No description available in the introspection data.
constructSocketLocalAddress :: (IsSocket o, IsAddress a) => a -> IO (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “local-address
” property. This is rarely needed directly, but it is used by new
.
getSocketLocalAddress :: (MonadIO m, IsSocket o) => o -> m Address Source #
Get the value of the “local-address
” property.
When overloading is enabled, this is equivalent to
get
socket #localAddress
nonBlocking
Whether or not the socket uses non-blocking I/O.
'GI.Soup.Objects.Socket.Socket'\'s I/O methods are designed around the idea of
using a single codepath for both synchronous and
asynchronous I/O. If you want to read off a Socket
,
the "correct" way to do it is to call socketRead
or
socketReadUntil
repeatedly until you have read
everything you want. If it returns SocketIOStatusWouldBlock
at any point, stop reading and wait for it to emit the
Socket
::readable
signal. Then go back to the
reading-as-much-as-you-can loop. Likewise, for writing to a
Socket
, you should call socketWrite
either
until you have written everything, or it returns
SocketIOStatusWouldBlock
(in which case you wait for
Socket
::writable
and then go back into the loop).
Code written this way will work correctly with both
blocking and non-blocking sockets; blocking sockets will
simply never return SocketIOStatusWouldBlock
, and so the
code that handles that case just won't get used for them.
constructSocketNonBlocking :: IsSocket o => Bool -> IO (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “non-blocking
” property. This is rarely needed directly, but it is used by new
.
getSocketNonBlocking :: (MonadIO m, IsSocket o) => o -> m Bool Source #
Get the value of the “non-blocking
” property.
When overloading is enabled, this is equivalent to
get
socket #nonBlocking
setSocketNonBlocking :: (MonadIO m, IsSocket o) => o -> Bool -> m () Source #
Set the value of the “non-blocking
” property.
When overloading is enabled, this is equivalent to
set
socket [ #nonBlocking:=
value ]
remoteAddress
No description available in the introspection data.
constructSocketRemoteAddress :: (IsSocket o, IsAddress a) => a -> IO (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “remote-address
” property. This is rarely needed directly, but it is used by new
.
getSocketRemoteAddress :: (MonadIO m, IsSocket o) => o -> m Address Source #
Get the value of the “remote-address
” property.
When overloading is enabled, this is equivalent to
get
socket #remoteAddress
sslCreds
No description available in the introspection data.
constructSocketSslCreds :: IsSocket o => Ptr () -> IO (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “ssl-creds
” property. This is rarely needed directly, but it is used by new
.
getSocketSslCreds :: (MonadIO m, IsSocket o) => o -> m (Ptr ()) Source #
Get the value of the “ssl-creds
” property.
When overloading is enabled, this is equivalent to
get
socket #sslCreds
setSocketSslCreds :: (MonadIO m, IsSocket o) => o -> Ptr () -> m () Source #
Set the value of the “ssl-creds
” property.
When overloading is enabled, this is equivalent to
set
socket [ #sslCreds:=
value ]
sslFallback
No description available in the introspection data.
constructSocketSslFallback :: IsSocket o => Bool -> IO (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “ssl-fallback
” property. This is rarely needed directly, but it is used by new
.
getSocketSslFallback :: (MonadIO m, IsSocket o) => o -> m Bool Source #
Get the value of the “ssl-fallback
” property.
When overloading is enabled, this is equivalent to
get
socket #sslFallback
sslStrict
No description available in the introspection data.
constructSocketSslStrict :: IsSocket o => Bool -> IO (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “ssl-strict
” property. This is rarely needed directly, but it is used by new
.
getSocketSslStrict :: (MonadIO m, IsSocket o) => o -> m Bool Source #
Get the value of the “ssl-strict
” property.
When overloading is enabled, this is equivalent to
get
socket #sslStrict
timeout
No description available in the introspection data.
constructSocketTimeout :: IsSocket o => Word32 -> IO (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “timeout
” property. This is rarely needed directly, but it is used by new
.
getSocketTimeout :: (MonadIO m, IsSocket o) => o -> m Word32 Source #
Get the value of the “timeout
” property.
When overloading is enabled, this is equivalent to
get
socket #timeout
setSocketTimeout :: (MonadIO m, IsSocket o) => o -> Word32 -> m () Source #
Set the value of the “timeout
” property.
When overloading is enabled, this is equivalent to
set
socket [ #timeout:=
value ]
tlsCertificate
No description available in the introspection data.
getSocketTlsCertificate :: (MonadIO m, IsSocket o) => o -> m (Maybe TlsCertificate) Source #
Get the value of the “tls-certificate
” property.
When overloading is enabled, this is equivalent to
get
socket #tlsCertificate
tlsErrors
No description available in the introspection data.
getSocketTlsErrors :: (MonadIO m, IsSocket o) => o -> m [TlsCertificateFlags] Source #
Get the value of the “tls-errors
” property.
When overloading is enabled, this is equivalent to
get
socket #tlsErrors
trustedCertificate
No description available in the introspection data.
getSocketTrustedCertificate :: (MonadIO m, IsSocket o) => o -> m Bool Source #
Get the value of the “trusted-certificate
” property.
When overloading is enabled, this is equivalent to
get
socket #trustedCertificate
useThreadContext
Use mainContextGetThreadDefault
.
Since: 2.38
constructSocketUseThreadContext :: IsSocket o => Bool -> IO (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “use-thread-context
” property. This is rarely needed directly, but it is used by new
.
getSocketUseThreadContext :: (MonadIO m, IsSocket o) => o -> m Bool Source #
Get the value of the “use-thread-context
” property.
When overloading is enabled, this is equivalent to
get
socket #useThreadContext
Signals
disconnected
type C_SocketDisconnectedCallback = Ptr () -> Ptr () -> IO () Source #
Type for the callback on the (unwrapped) C side.
type SocketDisconnectedCallback = IO () Source #
Emitted when the socket is disconnected, for whatever reason.
afterSocketDisconnected :: (IsSocket a, MonadIO m) => a -> SocketDisconnectedCallback -> m SignalHandlerId Source #
Connect a signal handler for the “disconnected
” signal, to be run after the default handler.
When overloading is enabled, this is equivalent to
after
socket #disconnected callback
genClosure_SocketDisconnected :: MonadIO m => SocketDisconnectedCallback -> m (GClosure C_SocketDisconnectedCallback) Source #
Wrap the callback into a GClosure
.
mk_SocketDisconnectedCallback :: C_SocketDisconnectedCallback -> IO (FunPtr C_SocketDisconnectedCallback) Source #
Generate a function pointer callable from C code, from a C_SocketDisconnectedCallback
.
noSocketDisconnectedCallback :: Maybe SocketDisconnectedCallback Source #
A convenience synonym for
.Nothing
:: Maybe
SocketDisconnectedCallback
onSocketDisconnected :: (IsSocket a, MonadIO m) => a -> SocketDisconnectedCallback -> m SignalHandlerId Source #
Connect a signal handler for the “disconnected
” signal, to be run before the default handler.
When overloading is enabled, this is equivalent to
on
socket #disconnected callback
wrap_SocketDisconnectedCallback :: SocketDisconnectedCallback -> C_SocketDisconnectedCallback Source #
Wrap a SocketDisconnectedCallback
into a C_SocketDisconnectedCallback
.
event
type C_SocketEventCallback = Ptr () -> CUInt -> Ptr IOStream -> Ptr () -> IO () Source #
Type for the callback on the (unwrapped) C side.
type SocketEventCallback Source #
= SocketClientEvent |
|
-> IOStream |
|
-> IO () |
Emitted when a network-related event occurs. See
SocketClient
::event
for more details.
Since: 2.38
afterSocketEvent :: (IsSocket a, MonadIO m) => a -> SocketEventCallback -> m SignalHandlerId Source #
Connect a signal handler for the “event
” signal, to be run after the default handler.
When overloading is enabled, this is equivalent to
after
socket #event callback
genClosure_SocketEvent :: MonadIO m => SocketEventCallback -> m (GClosure C_SocketEventCallback) Source #
Wrap the callback into a GClosure
.
mk_SocketEventCallback :: C_SocketEventCallback -> IO (FunPtr C_SocketEventCallback) Source #
Generate a function pointer callable from C code, from a C_SocketEventCallback
.
noSocketEventCallback :: Maybe SocketEventCallback Source #
A convenience synonym for
.Nothing
:: Maybe
SocketEventCallback
onSocketEvent :: (IsSocket a, MonadIO m) => a -> SocketEventCallback -> m SignalHandlerId Source #
Connect a signal handler for the “event
” signal, to be run before the default handler.
When overloading is enabled, this is equivalent to
on
socket #event callback
wrap_SocketEventCallback :: SocketEventCallback -> C_SocketEventCallback Source #
Wrap a SocketEventCallback
into a C_SocketEventCallback
.
newConnection
type C_SocketNewConnectionCallback = Ptr () -> Ptr Socket -> Ptr () -> IO () Source #
Type for the callback on the (unwrapped) C side.
type SocketNewConnectionCallback Source #
Emitted when a listening socket (set up with
socketListen
) receives a new connection.
You must ref the new
if you want to keep it; otherwise it
will be destroyed after the signal is emitted.
afterSocketNewConnection :: (IsSocket a, MonadIO m) => a -> SocketNewConnectionCallback -> m SignalHandlerId Source #
Connect a signal handler for the “new-connection
” signal, to be run after the default handler.
When overloading is enabled, this is equivalent to
after
socket #newConnection callback
genClosure_SocketNewConnection :: MonadIO m => SocketNewConnectionCallback -> m (GClosure C_SocketNewConnectionCallback) Source #
Wrap the callback into a GClosure
.
mk_SocketNewConnectionCallback :: C_SocketNewConnectionCallback -> IO (FunPtr C_SocketNewConnectionCallback) Source #
Generate a function pointer callable from C code, from a C_SocketNewConnectionCallback
.
noSocketNewConnectionCallback :: Maybe SocketNewConnectionCallback Source #
A convenience synonym for
.Nothing
:: Maybe
SocketNewConnectionCallback
onSocketNewConnection :: (IsSocket a, MonadIO m) => a -> SocketNewConnectionCallback -> m SignalHandlerId Source #
Connect a signal handler for the “new-connection
” signal, to be run before the default handler.
When overloading is enabled, this is equivalent to
on
socket #newConnection callback
wrap_SocketNewConnectionCallback :: SocketNewConnectionCallback -> C_SocketNewConnectionCallback Source #
Wrap a SocketNewConnectionCallback
into a C_SocketNewConnectionCallback
.
readable
type C_SocketReadableCallback = Ptr () -> Ptr () -> IO () Source #
Type for the callback on the (unwrapped) C side.
type SocketReadableCallback = IO () Source #
Emitted when an async socket is readable. See
socketRead
, socketReadUntil
and
Socket
:non-blocking
.
afterSocketReadable :: (IsSocket a, MonadIO m) => a -> SocketReadableCallback -> m SignalHandlerId Source #
Connect a signal handler for the “readable
” signal, to be run after the default handler.
When overloading is enabled, this is equivalent to
after
socket #readable callback
genClosure_SocketReadable :: MonadIO m => SocketReadableCallback -> m (GClosure C_SocketReadableCallback) Source #
Wrap the callback into a GClosure
.
mk_SocketReadableCallback :: C_SocketReadableCallback -> IO (FunPtr C_SocketReadableCallback) Source #
Generate a function pointer callable from C code, from a C_SocketReadableCallback
.
noSocketReadableCallback :: Maybe SocketReadableCallback Source #
A convenience synonym for
.Nothing
:: Maybe
SocketReadableCallback
onSocketReadable :: (IsSocket a, MonadIO m) => a -> SocketReadableCallback -> m SignalHandlerId Source #
Connect a signal handler for the “readable
” signal, to be run before the default handler.
When overloading is enabled, this is equivalent to
on
socket #readable callback
wrap_SocketReadableCallback :: SocketReadableCallback -> C_SocketReadableCallback Source #
Wrap a SocketReadableCallback
into a C_SocketReadableCallback
.
writable
type C_SocketWritableCallback = Ptr () -> Ptr () -> IO () Source #
Type for the callback on the (unwrapped) C side.
type SocketWritableCallback = IO () Source #
Emitted when an async socket is writable. See
socketWrite
and Socket
:non-blocking
.
afterSocketWritable :: (IsSocket a, MonadIO m) => a -> SocketWritableCallback -> m SignalHandlerId Source #
Connect a signal handler for the “writable
” signal, to be run after the default handler.
When overloading is enabled, this is equivalent to
after
socket #writable callback
genClosure_SocketWritable :: MonadIO m => SocketWritableCallback -> m (GClosure C_SocketWritableCallback) Source #
Wrap the callback into a GClosure
.
mk_SocketWritableCallback :: C_SocketWritableCallback -> IO (FunPtr C_SocketWritableCallback) Source #
Generate a function pointer callable from C code, from a C_SocketWritableCallback
.
noSocketWritableCallback :: Maybe SocketWritableCallback Source #
A convenience synonym for
.Nothing
:: Maybe
SocketWritableCallback
onSocketWritable :: (IsSocket a, MonadIO m) => a -> SocketWritableCallback -> m SignalHandlerId Source #
Connect a signal handler for the “writable
” signal, to be run before the default handler.
When overloading is enabled, this is equivalent to
on
socket #writable callback