conduit-extra-1.3.3: Batteries included conduit: adapters for common libraries.

Safe Haskell | None
Language | Haskell98

Data.Conduit.Network.UDP

Contents

- UDP message representation
- Basic utilities
- Helper Utilities

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

data Message Source #

Representation of a single UDP message

Constructors

Message |

Fields

- msgData :: !ByteString
- msgSender :: !SockAddr

# Basic utilities

sourceSocket :: MonadIO m => Socket -> Int -> ConduitT i Message m () Source #

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 () Source #

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 () Source #

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 () Source #

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 () Source #

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

Which host to bind.

Note: The `IsString` instance recognizes the following special values:

- `*` means `HostAny` - "any IPv4 or IPv6 hostname"
- `*4` means `HostIPv4` - "any IPv4 or IPv6 hostname, IPv4 preferred"
- `!4` means `HostIPv4Only` - "any IPv4 hostname"
- `*6` means `HostIPv6`@ - "any IPv4 or IPv6 hostname, IPv6 preferred"
- `!6` means `HostIPv6Only` - "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".

Instances

Eq HostPreference |
Instance details Defined in Data.Streaming.Network.Internal Methods (==) :: HostPreference -> HostPreference -> Bool Source # (/=) :: HostPreference -> HostPreference -> Bool Source #
Ord HostPreference |

Instance details

Defined in Data.Streaming.Network.Internal

Methods

compare :: HostPreference -> HostPreference -> Ordering Source #

(<) :: HostPreference -> HostPreference -> Bool Source #

(<=) :: HostPreference -> HostPreference -> Bool Source #

(>) :: HostPreference -> HostPreference -> Bool Source #

(>=) :: HostPreference -> HostPreference -> Bool Source #

max :: HostPreference -> HostPreference -> HostPreference Source #

min :: HostPreference -> HostPreference -> HostPreference Source #

Read HostPreference |
Instance details Defined in Data.Streaming.Network.Internal Methods readsPrec :: Int -> ReadS HostPreference Source # readList :: ReadS [HostPreference] Source # readPrec :: ReadPrec HostPreference Source # readListPrec :: ReadPrec [HostPreference] Source #
Show HostPreference |
Instance details Defined in Data.Streaming.Network.Internal Methods showsPrec :: Int -> HostPreference -> ShowS Source # show :: HostPreference -> String Source # showList :: [HostPreference] -> ShowS Source #
IsString HostPreference |
Instance details Defined in Data.Streaming.Network.Internal Methods fromString :: String -> HostPreference Source #