Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- uninterruptibleAccept4 :: Fd -> CInt -> SocketFlags -> IO (Either Errno (CInt, SocketAddress, Fd))
- uninterruptibleAccept4_ :: Fd -> SocketFlags -> IO (Either Errno Fd)
- newtype SocketFlags = SocketFlags CInt
- headerInclude :: OptionName
- dontWait :: MessageFlags m
- truncate :: MessageFlags Receive
- controlTruncate :: MessageFlags Receive
- closeOnExec :: SocketFlags
- nonblocking :: SocketFlags
- applySocketFlags :: SocketFlags -> Type -> Type
- sizeofUdpHeader :: CInt
- pokeUdpHeaderSourcePort :: Addr -> Word16 -> IO ()
- pokeUdpHeaderDestinationPort :: Addr -> Word16 -> IO ()
- pokeUdpHeaderLength :: Addr -> Word16 -> IO ()
- pokeUdpHeaderChecksum :: Addr -> Word16 -> IO ()
- sizeofIpHeader :: CInt
- pokeIpHeaderVersionIhl :: Addr -> Word8 -> IO ()
- pokeIpHeaderTypeOfService :: Addr -> Word8 -> IO ()
- pokeIpHeaderTotalLength :: Addr -> Word16 -> IO ()
- pokeIpHeaderIdentifier :: Addr -> Word16 -> IO ()
- pokeIpHeaderFragmentOffset :: Addr -> Word16 -> IO ()
- pokeIpHeaderTimeToLive :: Addr -> Word8 -> IO ()
- pokeIpHeaderProtocol :: Addr -> Word8 -> IO ()
- pokeIpHeaderChecksum :: Addr -> Word16 -> IO ()
- pokeIpHeaderSourceAddress :: Addr -> Word32 -> IO ()
- pokeIpHeaderDestinationAddress :: Addr -> Word32 -> IO ()
Functions
uninterruptibleAccept4 Source #
:: Fd | Listening socket |
-> CInt | Maximum socket address size |
-> SocketFlags | Set non-blocking and close-on-exec without extra syscall |
-> IO (Either Errno (CInt, SocketAddress, Fd)) | Peer information and connected socket |
Variant of uninterruptibleAccept
that allows setting
flags on the newly-accepted connection.
uninterruptibleAccept4_ Source #
:: Fd | Listening socket |
-> SocketFlags | Set non-blocking and close-on-exec without extra syscall |
-> IO (Either Errno Fd) | Connected socket |
Variant of uninterruptibleAccept4
that requests that the kernel not
include the socket address in its reponse.
Types
newtype SocketFlags Source #
Instances
Option Names
headerInclude :: OptionName Source #
If enabled, the user supplies an IP header in front of the
user data. Valid only for SOCK_RAW
sockets.
Message Flags
dontWait :: MessageFlags m Source #
The MSG_DONTWAIT
receive flag or send flag.
truncate :: MessageFlags Receive Source #
The MSG_TRUNC
receive flag.
controlTruncate :: MessageFlags Receive Source #
The MSG_CTRUNC
receive flag.
Socket Flags
closeOnExec :: SocketFlags Source #
The SOCK_CLOEXEC
receive flag or send flag.
nonblocking :: SocketFlags Source #
The SOCK_NONBLOCK
receive flag or send flag.
Twiddle
applySocketFlags :: SocketFlags -> Type -> Type Source #
Linux extends the type
argument of
socket to allow
setting two socket flags on socket creation: SOCK_CLOEXEC
and
SOCK_NONBLOCK
. It is advisable to set SOCK_CLOEXEC
on when
opening a socket on linux. For example, we may open a TCP Internet
socket with:
uninterruptibleSocket internet (applySocketFlags closeOnExec stream) defaultProtocol
To additionally open the socket in nonblocking mode
(e.g. with SOCK_NONBLOCK
):
uninterruptibleSocket internet (applySocketFlags (closeOnExec <> nonblocking) stream) defaultProtocol
UDP Header
sizeofUdpHeader :: CInt Source #
The size of a udphdr
struct.
IPv4 Header
sizeofIpHeader :: CInt Source #
The size of an iphdr
struct.
pokeIpHeaderVersionIhl :: Addr -> Word8 -> IO () Source #
This poke function requires the user to pack the version and the internet header length (IHL), each 4 bits, into a single 8-bit word. The version should be in the most significant bits. This function will marshal the value appropriately depending on the platform's bit-endianness.