Safe Haskell | None |
---|---|
Language | Haskell98 |
Synopsis
- data Message = Message {
- msgData :: !ByteString
- msgSender :: !SockAddr
- sourceSocket :: MonadIO m => Socket -> Int -> ConduitT i Message m ()
- sinkSocket :: MonadIO m => Socket -> ConduitT ByteString o m ()
- sinkAllSocket :: MonadIO m => Socket -> ConduitT ByteString o m ()
- sinkToSocket :: MonadIO m => Socket -> ConduitT Message o m ()
- sinkAllToSocket :: MonadIO m => Socket -> ConduitT Message o m ()
- data HostPreference
UDP message representation
Representation of a single UDP message
Message | |
|
Basic utilities
sourceSocket :: MonadIO m => Socket -> Int -> ConduitT i Message m () #
Stream messages from the socket.
The given len
defines the maximum packet size. Every produced item
contains the message payload and the origin address.
This function does not automatically close the socket.
sinkSocket :: MonadIO m => Socket -> ConduitT ByteString o m () #
Stream messages to the connected socket.
The payload is sent using send
, so some of it might be lost.
This function does not automatically close the socket.
sinkAllSocket :: MonadIO m => Socket -> ConduitT ByteString o m () #
Stream messages to the connected socket.
The payload is sent using sendAll
, so it might end up in multiple packets.
This function does not automatically close the socket.
sinkToSocket :: MonadIO m => Socket -> ConduitT Message o m () #
Stream messages to the socket.
Every handled item contains the message payload and the destination
address. The payload is sent using sendTo
, so some of it might be
lost.
This function does not automatically close the socket.
sinkAllToSocket :: MonadIO m => Socket -> ConduitT Message o m () #
Stream messages to the socket.
Every handled item contains the message payload and the destination
address. The payload is sent using sendAllTo
, so it might end up in
multiple packets.
This function does not automatically close the socket.
Helper Utilities
data HostPreference #
Which host to bind.
Note: The IsString
instance recognizes the following special values:
*
meansHostAny
- "any IPv4 or IPv6 hostname"*4
meansHostIPv4
- "any IPv4 or IPv6 hostname, IPv4 preferred"!4
meansHostIPv4Only
- "any IPv4 hostname"*6
meansHostIPv6
@ - "any IPv4 or IPv6 hostname, IPv6 preferred"!6
meansHostIPv6Only
- "any IPv6 hostname"
Note that the permissive *
values allow binding to an IPv4 or an
IPv6 hostname, which means you might be able to successfully bind
to a port more times than you expect (eg once on the IPv4 localhost
127.0.0.1 and again on the IPv6 localhost 0:0:0:0:0:0:0:1).
Any other value is treated as a hostname. As an example, to bind to the IPv4 local host only, use "127.0.0.1".