conduit-extra-1.3.5: Batteries included conduit: adapters for common libraries.
Safe HaskellNone
LanguageHaskell98

Data.Conduit.Network.UDP

Synopsis

UDP message representation

data Message #

Representation of a single UDP message

Constructors

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:

  • * 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".