posix-api-0.2.0.0: posix bindings

Safe HaskellNone
LanguageHaskell2010

Linux.Socket

Contents

Synopsis

Types

newtype SocketFlags Source #

Constructors

SocketFlags CInt 
Instances
Eq SocketFlags Source # 
Instance details

Defined in Linux.Socket.Types

Semigroup SocketFlags Source # 
Instance details

Defined in Linux.Socket.Types

Monoid SocketFlags Source # 
Instance details

Defined in Linux.Socket.Types

Bits SocketFlags Source # 
Instance details

Defined in Linux.Socket.Types

Message Flags

dontWait :: MessageFlags m Source #

The MSG_DONTWAIT receive flag or send flag.

truncate :: MessageFlags m Source #

The MSG_TRUNC 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 accept flags. 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