Running a UDP client with a socket. The client action takes a socket and server's socket address. They should be used with sendTo.
Modulenetwork-run-0.6.0Haskell2010
Network.Run.UDP
Simple functions to run UDP clients and servers.
- 1 type
- 9 values
- Packagenetwork-run-0.6.0
- Exports10
- LanguageHaskell2010
- LicenceBSD-3-Clause
- SourceUDP.hs
Running a UDP server with an open socket in a single Haskell thread.
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.
runUDPServerFork with the given settings.
Settings for servers.
Fields which do not apply to a given server (for instance the graceful close timeout for a UDP server) are ignored.
Constructors
ServerSettingssettingsOnException :: Maybe SockAddr -> SomeException -> IO ()settingsGracefulCloseTimeout :: IntMilliseconds gracefulClose waits for the peer's FIN after a connection handler returns. Zero or less uses close instead, which releases the file descriptor immediately. The default is 5000.
settingsAcceptRetryDelay :: IntMicroseconds to wait before retrying accept after running out of file descriptors. The default is 100000.
Default settings. settingsOnException does nothing, so the behaviour is the same as before this type was introduced.
Open socket for server use, and set the provided options before binding.
This is equivalent to
openServerSocketWithOpts . map (second (SockOptValue . fromIntegral @Int @CInt))
Open socket for server use, and set the provided options before binding.
In addition to the given options, the socket is configured to
allow reuse of local addresses (SO_REUSEADDR)
accept IPv6 only, rejecting IPv4-mapped addresses, if the address family is AF_INET6 (IPV6_V6ONLY)
automatically be closed during a successful
execve(FD_CLOEXEC)bind to the address specified
Because IPV6_V6ONLY is in effect, a socket bound to :: does not
accept IPv4 connections. To serve both families, open one socket per
address and run a server on each of them with
runTCPServerWithSocket.
The given options are set after the ones above, so (IPv6Only, 0)
can be passed to ask for a dual stack socket. Note that OpenBSD
always makes IPv6 sockets IPv6 only; the option is not set there and
cannot be cleared.