Portability | portable |
---|---|
Stability | provisional |
Maintainer | libraries@haskell.org |
Safe Haskell | Safe-Inferred |
- type HostAddress = Word32
- type HostAddress6 = (Word32, Word32, Word32, Word32)
- type FlowInfo = Word32
- type ScopeID = Word32
- newtype PortNumber = PortNum Word16
- data SockAddr
- peekSockAddr :: Ptr SockAddr -> IO SockAddr
- pokeSockAddr :: Ptr a -> SockAddr -> IO ()
- sizeOfSockAddr :: SockAddr -> Int
- sizeOfSockAddrByFamily :: Family -> Int
- withSockAddr :: SockAddr -> (Ptr SockAddr -> Int -> IO a) -> IO a
- withNewSockAddr :: Family -> (Ptr SockAddr -> Int -> IO a) -> IO a
- data Family
- = AF_UNSPEC
- | AF_UNIX
- | AF_INET
- | AF_INET6
- | AF_IMPLINK
- | AF_PUP
- | AF_CHAOS
- | AF_NS
- | AF_NBS
- | AF_ECMA
- | AF_DATAKIT
- | AF_CCITT
- | AF_SNA
- | AF_DECnet
- | AF_DLI
- | AF_LAT
- | AF_HYLINK
- | AF_APPLETALK
- | AF_ROUTE
- | AF_NETBIOS
- | AF_NIT
- | AF_802
- | AF_ISO
- | AF_OSI
- | AF_NETMAN
- | AF_X25
- | AF_AX25
- | AF_OSINET
- | AF_GOSSIP
- | AF_IPX
- | Pseudo_AF_XTP
- | AF_CTF
- | AF_WAN
- | AF_SDL
- | AF_NETWARE
- | AF_NDD
- | AF_INTF
- | AF_COIP
- | AF_CNT
- | Pseudo_AF_RTIP
- | Pseudo_AF_PIP
- | AF_SIP
- | AF_ISDN
- | Pseudo_AF_KEY
- | AF_NATM
- | AF_ARP
- | Pseudo_AF_HDRCMPLT
- | AF_ENCAP
- | AF_LINK
- | AF_RAW
- | AF_RIF
- | AF_NETROM
- | AF_BRIDGE
- | AF_ATMPVC
- | AF_ROSE
- | AF_NETBEUI
- | AF_SECURITY
- | AF_PACKET
- | AF_ASH
- | AF_ECONET
- | AF_ATMSVC
- | AF_IRDA
- | AF_PPPOX
- | AF_WANPIPE
- | AF_BLUETOOTH
- throwSocketError :: String -> IO a
- throwSocketErrorIfMinus1_ :: (Eq a, Num a) => String -> IO a -> IO ()
- throwSocketErrorIfMinus1Retry :: (Eq a, Num a) => String -> IO a -> IO a
- throwSocketErrorIfMinus1RetryMayBlock :: (Eq a, Num a) => String -> IO b -> IO a -> IO a
- withSocketsDo :: IO a -> IO a
- zeroMemory :: Ptr a -> CSize -> IO ()
Socket addresses
type HostAddress = Word32Source
Network byte order.
newtype PortNumber Source
pokeSockAddr :: Ptr a -> SockAddr -> IO ()Source
Write the given SockAddr
to the given memory location.
sizeOfSockAddr :: SockAddr -> IntSource
Protocol families
Address families.
A constructor being present here does not mean it is supported by the
operating system: see isSupportedFamily
.
Socket error functions
Throw an IOError
corresponding to the current socket error.
Guards for socket operations that may fail
throwSocketErrorIfMinus1_Source
:: (Eq a, Num a) | |
=> String | textual description of the location |
-> IO a | the |
-> IO () |
Throw an IOError
corresponding to the current socket error if
the IO action returns a result of -1
. Discards the result of the
IO action after error handling.
throwSocketErrorIfMinus1RetrySource
:: (Eq a, Num a) | |
=> String | textual description of the location |
-> IO a | the |
-> IO a |
Throw an IOError
corresponding to the current socket error if
the IO action returns a result of -1
, but retries in case of an
interrupted operation.
throwSocketErrorIfMinus1RetryMayBlockSource
:: (Eq a, Num a) | |
=> String | textual description of the location |
-> IO b | action to execute before retrying if an immediate retry would block |
-> IO a | the |
-> IO a |
Throw an IOError
corresponding to the current socket error if
the IO action returns a result of -1
, but retries in case of an
interrupted operation. Checks for operations that would block and
executes an alternative action before retrying in that case.
Initialization
withSocketsDo :: IO a -> IO aSource
On Windows operating systems, the networking subsystem has to be
initialised using withSocketsDo
before any networking operations can
be used. eg.
main = withSocketsDo $ do {...}
Although this is only strictly necessary on Windows platforms, it is harmless on other platforms, so for portability it is good practice to use it all the time.
Low-level helpers
zeroMemory :: Ptr a -> CSize -> IO ()Source
Zero a structure.