Copyright | (c) Winterland 2018 |
---|---|
License | BSD |
Maintainer | drkoster@qq.com |
Stability | experimental |
Portability | non-portable |
Safe Haskell | None |
Language | Haskell2010 |
This module provides necessary types and constant for low level socket operation.
Synopsis
- data SockAddr
- sockAddrFamily :: SockAddr -> SocketFamily
- peekSockAddr :: HasCallStack => Ptr SockAddr -> IO SockAddr
- withSockAddr :: SockAddr -> (Ptr SockAddr -> IO a) -> IO a
- withSockAddrStorage :: (Ptr SockAddr -> Ptr CInt -> IO ()) -> IO SockAddr
- data InetAddr
- inetAny :: InetAddr
- inetBroadcast :: InetAddr
- inetNone :: InetAddr
- inetLoopback :: InetAddr
- inetUnspecificGroup :: InetAddr
- inetAllHostsGroup :: InetAddr
- inetMaxLocalGroup :: InetAddr
- inetAddrToTuple :: InetAddr -> (Word8, Word8, Word8, Word8)
- tupleToInetAddr :: (Word8, Word8, Word8, Word8) -> InetAddr
- data Inet6Addr
- inet6Any :: Inet6Addr
- inet6Loopback :: Inet6Addr
- inet6AddrToTuple :: Inet6Addr -> (Word16, Word16, Word16, Word16, Word16, Word16, Word16, Word16)
- tupleToInet6Addr :: (Word16, Word16, Word16, Word16, Word16, Word16, Word16, Word16) -> Inet6Addr
- type FlowInfo = Word32
- type ScopeID = Word32
- data PortNumber
- aNY_PORT :: PortNumber
- htons :: Word16 -> Word16
- ntohs :: Word16 -> Word16
- ntohl :: Word32 -> Word32
- htonl :: Word32 -> Word32
- newtype SocketFamily = SocketFamily CInt
- pattern AF_UNSPEC :: SocketFamily
- pattern AF_INET :: SocketFamily
- pattern AF_INET6 :: SocketFamily
- newtype SocketType = SocketType CInt
- pattern SOCK_DGRAM :: SocketType
- pattern SOCK_STREAM :: SocketType
- pattern SOCK_SEQPACKET :: SocketType
- pattern SOCK_RAW :: SocketType
- pattern SOCK_RDM :: SocketType
- newtype SocketProtocol = SocketProtocol CInt
- pattern IPPROTO_TCP :: SocketProtocol
- pattern IPPROTO_UDP :: SocketProtocol
name to address
IPv4 or IPv6 socket address, i.e. the sockaddr_in
or sockaddr_in6
struct.
peekSockAddr :: HasCallStack => Ptr SockAddr -> IO SockAddr Source #
IPv4 address
Independent of endianness. For example 127.0.0.1
is stored as (127, 0, 0, 1)
.
For direct manipulation prefer inetAddrToTuple
and tupleToInetAddr
.
Instances
Eq InetAddr Source # | |
Ord InetAddr Source # | |
Defined in Std.IO.SockAddr | |
Show InetAddr Source # | |
Storable InetAddr Source # | |
inetBroadcast :: InetAddr Source #
255.255.255.255
inetLoopback :: InetAddr Source #
127.0.0.1
inetUnspecificGroup :: InetAddr Source #
224.0.0.0
inetAllHostsGroup :: InetAddr Source #
224.0.0.1
inetMaxLocalGroup :: InetAddr Source #
224.0.0.255
inetAddrToTuple :: InetAddr -> (Word8, Word8, Word8, Word8) Source #
Converts HostAddress
to representation-independent IPv4 quadruple.
For example for 127.0.0.1
the function will return (127, 0, 0, 1)
regardless of host endianness.
tupleToInetAddr :: (Word8, Word8, Word8, Word8) -> InetAddr Source #
Converts IPv4 quadruple to HostAddress
.
IPv6 address
Independent of endianness. For example ::1
is stored as (0, 0, 0, 1)
.
For direct manipulation prefer inet6AddrToTuple
and tupleToInet6Addr
.
Instances
Eq Inet6Addr Source # | |
Ord Inet6Addr Source # | |
Defined in Std.IO.SockAddr | |
Show Inet6Addr Source # | |
Storable Inet6Addr Source # | |
Defined in Std.IO.SockAddr |
inet6Loopback :: Inet6Addr Source #
::1
inet6AddrToTuple :: Inet6Addr -> (Word16, Word16, Word16, Word16, Word16, Word16, Word16, Word16) Source #
tupleToInet6Addr :: (Word16, Word16, Word16, Word16, Word16, Word16, Word16, Word16) -> Inet6Addr Source #
port numbber
data PortNumber Source #
Use the Num
instance (i.e. use a literal or fromIntegral
) to create a
PortNumber
value with the correct network-byte-ordering.
>>>
1 :: PortNumber
1>>>
read "1" :: PortNumber
1
Instances
family, type, protocol
newtype SocketFamily Source #
Instances
pattern AF_UNSPEC :: SocketFamily Source #
unspecified
pattern AF_INET :: SocketFamily Source #
internetwork: UDP, TCP, etc
pattern AF_INET6 :: SocketFamily Source #
Internet Protocol version 6
newtype SocketType Source #
Instances
pattern SOCK_DGRAM :: SocketType Source #
pattern SOCK_STREAM :: SocketType Source #
pattern SOCK_SEQPACKET :: SocketType Source #
pattern SOCK_RAW :: SocketType Source #
pattern SOCK_RDM :: SocketType Source #
newtype SocketProtocol Source #
Instances
pattern IPPROTO_TCP :: SocketProtocol Source #
pattern IPPROTO_UDP :: SocketProtocol Source #