posix-api-0.7.2.0: posix bindings
Safe HaskellSafe-Inferred
LanguageHaskell2010

Linux.Socket

Synopsis

Functions

uninterruptibleAccept4 Source #

Arguments

:: 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 #

Arguments

:: 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 #

Constructors

SocketFlags CInt 

Instances

Instances details
Monoid SocketFlags Source # 
Instance details

Defined in Linux.Socket.Types

Semigroup SocketFlags Source # 
Instance details

Defined in Linux.Socket.Types

Bits SocketFlags Source # 
Instance details

Defined in Linux.Socket.Types

Eq SocketFlags Source # 
Instance details

Defined in Linux.Socket.Types

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.