hans- IPv4 Network Stack

Safe HaskellNone




type UdpHandle = Channel (Udp ()) Source

queueUdp :: UdpHandle -> IP4Header -> ByteString -> IO () Source

Queue an incoming udp message from the IP4 layer.

sendUdp :: UdpHandle -> IP4 -> Maybe UdpPort -> UdpPort -> ByteString -> IO () Source

Send a UDP datagram. When the source port is given, this will send using that source port. If the source port is not given, a fresh one is used, and immediately recycled.

NOTE: this doesn't prevent you from sending messages on a port that another thread is already using. This is a funky design, and we'd be better suited by introducing a UdpSocket type.

type Handler = IP4 -> UdpPort -> ByteString -> IO () Source

addUdpHandler :: UdpHandle -> UdpPort -> Handler -> IO () Source

Add a handler for incoming udp datagrams on a specific port.

addUdpHandlerAnyPort :: UdpHandle -> (UdpPort -> Handler) -> IO UdpPort Source

Add a handler for incoming udp datagrams on a freshly allocated port.

removeUdpHandler :: UdpHandle -> UdpPort -> IO () Source

Remove a handler present on the port given.