Description: Correctly retrieve the type of the socket On mips, `SOCK_STREAM` and `SOCK_DGRAM` have different values than on x86_64. Modify `getSockType` to use functions from the Network library to retrieve the type of the socket, instead of relying on hard-coded values. Author: Ilias Tsitsimpis Bug: https://github.com/snapframework/io-streams-haproxy/issues/18 Index: b/src/System/IO/Streams/Network/HAProxy.hs =================================================================== --- a/src/System/IO/Streams/Network/HAProxy.hs +++ b/src/System/IO/Streams/Network/HAProxy.hs @@ -72,15 +72,8 @@ socketToProxyInfo s sa = do !sty <- getSockType return $! makeProxyInfo sa da (addrFamily sa) sty where -#if MIN_VERSION_network(2,7,0) - getSockType = do - c <- N.getSocketOption s N.Type - -- This is a kludge until network has better support for returning - -- SocketType - case c of - 1 -> return N.Stream - 2 -> return N.Datagram - _ -> error ("bad socket type: " ++ show c) +#if MIN_VERSION_network(3,0,1) + getSockType = N.getSocketType s #else getSockType = let (N.MkSocket _ _ sty _ _) = s in return sty #endif