Safe Haskell | None |
---|
Converting an address in SockAddr
.
- showSockAddr :: SockAddr -> String
- showSockAddrBS :: SockAddr -> ByteString
Documentation
showSockAddr :: SockAddr -> StringSource
Convert SockAddr
to String
. If the address is
an IPv4-embedded IPv6 address, the IPv4 is extracted.
>>>
import Network.Socket
>>>
as <- getAddrInfo (Just defaultHints) (Just "example.org") (Just "http")
>>>
map (showSockAddr.addrAddress) as
["93.184.216.119","93.184.216.119","2606:2800:220:6d:26bf:1447:1097:aa7","2606:2800:220:6d:26bf:1447:1097:aa7"]
showSockAddrBS :: SockAddr -> ByteStringSource
Convert SockAddr
to ByteString
. If the address is
an IPv4-embedded IPv6 address, the IPv4 is extracted.
>>>
import Network.Socket
>>>
as <- getAddrInfo (Just defaultHints) (Just "localhost") (Just "http")
>>>
map (showSockAddrBS.addrAddress) as
["127.0.0.1","::1","fe80:0:0:0:0:0:0:1"]