1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
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 <iliastsi@debian.org>
Bug: https://github.com/snapframework/io-streams-haproxy/issues/18
--- a/src/System/IO/Streams/Network/HAProxy.hs
+++ b/src/System/IO/Streams/Network/HAProxy.hs
@@ -72,15 +72,8 @@
!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
|