diff --git a/Network/Socket/Info.hsc b/Network/Socket/Info.hsc index eb294dd8..21a0f464 100644 --- a/Network/Socket/Info.hsc +++ b/Network/Socket/Info.hsc @@ -1,4 +1,5 @@ {-# OPTIONS_GHC -fno-warn-orphans #-} +{-# LANGUAGE RecordWildCards #-} #include "HsNet.h" ##include "HsNetDef.h" @@ -214,6 +215,26 @@ defaultHints = AddrInfo { addrCanonName = undefined } +-- | Shows the fields of 'defaultHints', without inspecting the by-default undefined fields 'addrAddress' and 'addrCanonName'. +showDefaultHints :: AddrInfo -> String +showDefaultHints AddrInfo{..} = concat + [ "AddrInfo {" + , "addrFlags = " + , show addrFlags + , ", addrFamily = " + , show addrFamily + , ", addrSocketType = " + , show addrSocketType + , ", addrProtocol = " + , show addrProtocol + , ", addrAddress = " + , "" + , ", addrCanonName = " + , "" + , "}" + ] + + ----------------------------------------------------------------------------- -- | Resolve a host or service name to one or more addresses. -- The 'AddrInfo' values that this function returns contain 'SockAddr' @@ -274,7 +295,7 @@ getAddrInfo hints node service = withSocketsDo $ _ -> do err <- gai_strerror ret let message = concat [ "Network.Socket.getAddrInfo (called with preferred socket type/protocol: " - , show hints + , maybe (show hints) showDefaultHints hints , ", host name: " , show node , ", service name: "