conduit-extra-1.1.9.2: 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 -> Producer m Message
- sinkSocket :: MonadIO m => Socket -> Consumer ByteString m ()
- sinkAllSocket :: MonadIO m => Socket -> Consumer ByteString m ()
- sinkToSocket :: MonadIO m => Socket -> Consumer Message m ()
- sinkAllToSocket :: MonadIO m => Socket -> Consumer Message m ()
- data HostPreference :: *

# UDP message representation

data Message :: *

Representation of a single UDP message

Constructors

Message |

Fields

msgData :: !ByteString
msgSender :: !SockAddr

# Basic utilities

sourceSocket :: MonadIO m => Socket -> Int -> Producer m Message 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 -> Consumer ByteString 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 -> Consumer ByteString 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 -> Consumer Message 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 -> Consumer Message 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 :: *

Which host to bind.

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

- `*` means `HostAny`
- `*4` means `HostIPv4`
- `!4` means `HostIPv4Only`
- `*6` means `HostIPv6`
- `!6` means `HostIPv6Only`

Any other values is treated as a hostname. As an example, to bind to the IPv4 local host only, use "127.0.0.1".

Instances

Eq HostPreference |
Ord HostPreference |
Read HostPreference |
Show HostPreference |
IsString HostPreference |