Data.Conduit.Network.UDP

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

Safe Haskell | None
Language | Haskell2010

Data.Conduit.Network.UDP

Contents

- UDP message representation
- Basic utilities
- Helper Utilities

Synopsis

- data Message = Message {
  - msgData :: !ByteString
  - msgSender :: !SockAddr
  }
- sourceSocket :: forall (m :: Type -> Type) i. MonadIO m => Socket -> Int -> ConduitT i Message m ()
- sinkSocket :: forall (m :: Type -> Type) o. MonadIO m => Socket -> ConduitT ByteString o m ()
- sinkAllSocket :: forall (m :: Type -> Type) o. MonadIO m => Socket -> ConduitT ByteString o m ()
- sinkToSocket :: forall (m :: Type -> Type) o. MonadIO m => Socket -> ConduitT Message o m ()
- sinkAllToSocket :: forall (m :: Type -> Type) o. MonadIO m => Socket -> ConduitT Message o m ()
- data HostPreference

# UDP message representation

data Message #

Representation of a single UDP message

Constructors

Message |
Fields msgData :: !ByteString msgSender :: !SockAddr

# Basic utilities

sourceSocket :: forall (m :: Type -> Type) i. 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 :: forall (m :: Type -> Type) o. 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 :: forall (m :: Type -> Type) o. 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 :: forall (m :: Type -> Type) o. 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 :: forall (m :: Type -> Type) o. 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:

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

Instances details

IsString HostPreference |
Instance details Defined in Data.Streaming.Network.Internal Methods fromString :: String -> HostPreference #
Read HostPreference |
Instance details Defined in Data.Streaming.Network.Internal Methods readsPrec :: Int -> ReadS HostPreference # readList :: ReadS [HostPreference] # readPrec :: ReadPrec HostPreference # readListPrec :: ReadPrec [HostPreference] #
Show HostPreference |
Instance details Defined in Data.Streaming.Network.Internal Methods showsPrec :: Int -> HostPreference -> ShowS # show :: HostPreference -> String # showList :: [HostPreference] -> ShowS #
Eq HostPreference |
Instance details Defined in Data.Streaming.Network.Internal Methods (==) :: HostPreference -> HostPreference -> Bool # (/=) :: HostPreference -> HostPreference -> Bool #
Ord HostPreference |
Instance details Defined in Data.Streaming.Network.Internal Methods compare :: HostPreference -> HostPreference -> Ordering # (<) :: HostPreference -> HostPreference -> Bool # (<=) :: HostPreference -> HostPreference -> Bool # (>) :: HostPreference -> HostPreference -> Bool # (>=) :: HostPreference -> HostPreference -> Bool # max :: HostPreference -> HostPreference -> HostPreference # min :: HostPreference -> HostPreference -> HostPreference #