network-run-0.4.4: Simple network runner library

Safe Haskell | None
Language | Haskell2010

Network.Run.UDP

Description

Simple functions to run UDP clients and servers.

Synopsis

- runUDPClient :: HostName -> ServiceName -> (Socket -> SockAddr -> IO a) -> IO a
- runUDPServer :: Maybe HostName -> ServiceName -> (Socket -> IO a) -> IO a
- runUDPServerFork :: [HostName] -> ServiceName -> (Socket -> ByteString -> IO ()) -> IO ()

# Documentation

runUDPClient :: HostName -> ServiceName -> (Socket -> SockAddr -> IO a) -> IO a Source #

Running a UDP client with a socket. The client action takes a socket and server's socket address. They should be used with `sendTo`.

runUDPServer :: Maybe HostName -> ServiceName -> (Socket -> IO a) -> IO a Source #

Running a UDP server with an open socket in a single Haskell thread.

runUDPServerFork :: [HostName] -> ServiceName -> (Socket -> ByteString -> IO ()) -> IO () Source #

Running a UDP server with a connected socket in each Haskell thread. The first request is given to the server. Suppose that the server is serving on addrS:portS and a client connects to the service from addrC:portC. A connected socket is created by binding to *:portS and connecting to addrC:portC, resulting in (UDP,addrS:portS,addrC:portC) where addrS is given magically. This approach is fragile due to NAT rebidings.