network-socket-options-0.1: Type-safe, portable alternative to getSocketOption/setSocketOption

Maintainerjoeyadams3.14159@gmail.com
Safe HaskellSafe-Infered

Network.Socket.Options

Contents

Description

Documentation is currently lacking. For now, see man 7 socket and man 7 tcp of the Linux man-pages, or look up setsockopt in MSDN.

Synopsis

Getting options

getAcceptConn :: HasSocket sock => sock -> IO BoolSource

This option is get-only.

getBroadcast :: HasSocket sock => sock -> IO BoolSource

getDebug :: HasSocket sock => sock -> IO BoolSource

getDontRoute :: HasSocket sock => sock -> IO BoolSource

getError :: HasSocket sock => sock -> IO IntSource

This option is get-only.

getKeepAlive :: HasSocket sock => sock -> IO BoolSource

getOOBInline :: HasSocket sock => sock -> IO BoolSource

getRecvBuf :: HasSocket sock => sock -> IO IntSource

getReuseAddr :: HasSocket sock => sock -> IO BoolSource

getSendBuf :: HasSocket sock => sock -> IO IntSource

getType :: HasSocket sock => sock -> IO SocketTypeSource

This option is get-only.

TCP

Setting options

setBroadcast :: HasSocket sock => sock -> Bool -> IO ()Source

setDebug :: HasSocket sock => sock -> Bool -> IO ()Source

setDontRoute :: HasSocket sock => sock -> Bool -> IO ()Source

setKeepAlive :: HasSocket sock => sock -> Bool -> IO ()Source

setLinger :: HasSocket sock => sock -> Maybe Seconds -> IO ()Source

On Windows, the Seconds value is truncated to 16 bits. This means if a linger time of more than 65535 seconds (about 18.2 hours) is given, it will wrap around.

setOOBInline :: HasSocket sock => sock -> Bool -> IO ()Source

setRecvBuf :: HasSocket sock => sock -> Int -> IO ()Source

setRecvTimeout :: HasSocket sock => sock -> Microseconds -> IO ()Source

Note the following about timeout values:

  • A value of 0 or less means the operation will never time out
  • On Windows, the timeout is truncated to milliseconds, 32-bit. However, if the number of microseconds is from 1 to 999, it will be rounded up to one millisecond, to prevent it from being treated as "never time out".

setReuseAddr :: HasSocket sock => sock -> Bool -> IO ()Source

setSendBuf :: HasSocket sock => sock -> Int -> IO ()Source

TCP

setTcpNoDelay :: HasSocket sock => sock -> Bool -> IO ()Source

Types

class HasSocket a whereSource

The getters and setters in this module can be used not only on Sockets, but on raw Fds (file descriptors) as well.

Methods

getSocket :: a -> CIntSource