sockaddr-0.0.0: Printing SockAddr

Safe Haskell | None
Language | Haskell2010

Network.SockAddr

Description

Converting an address in `SockAddr`.

Synopsis

- showSockAddr :: SockAddr -> String
- showSockAddrBS :: SockAddr -> ByteString

# Documentation

showSockAddr :: SockAddr -> String Source #

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 -> ByteString Source #

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"]