network-conduit-0.5.0.2: Stream socket data using conduits.

Safe HaskellNone

Data.Conduit.Network.UDP

Contents

Synopsis

UDP message representation

data Message Source

Representation of a single message

Constructors

Message 

Basic utilities

sourceSocket :: MonadIO m => Socket -> Int -> GSource m MessageSource

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 -> GInfSink ByteString mSource

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 -> GInfSink ByteString mSource

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 -> GInfSink Message mSource

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 -> GInfSink Message mSource

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
  • *4 means HostIPv4
  • *6 means HostIPv6

bindPort :: Int -> HostPreference -> IO SocketSource

Attempt to bind a listening Socket on the given host/port. If no host is given, will use the first address available.

getSocket :: String -> Int -> IO (Socket, AddrInfo)Source

Attempt to connect to the given host/port.