network 2.6.1.0 → 2.6.2.0
raw patch · 6 files changed
+41/−10 lines, 6 files
Files
- Network/Socket.hsc +5/−0
- Network/Socket/Types.hsc +19/−6
- configure.ac +1/−1
- include/HsNet.h +3/−1
- network.cabal +1/−1
- tests/Simple.hs +12/−1
Network/Socket.hsc view
@@ -33,6 +33,7 @@ , SocketType(..) , isSupportedSocketType , SockAddr(..)+ , isSupportedSockAddr , SocketStatus(..) , HostAddress #if defined(IPV6_SOCKET_SUPPORT)@@ -792,6 +793,7 @@ | RecvTimeOut -- ^ SO_RCVTIMEO | SendTimeOut -- ^ SO_SNDTIMEO | UseLoopBack -- ^ SO_USELOOPBACK+ | UserTimeout -- ^ TCP_USER_TIMEOUT | IPv6Only -- ^ IPV6_V6ONLY | CustomSockOpt (CInt, CInt) deriving (Show, Typeable)@@ -880,6 +882,9 @@ #endif #ifdef TCP_NODELAY Just NoDelay -> Just ((#const IPPROTO_TCP), (#const TCP_NODELAY))+#endif+#ifdef TCP_USER_TIMEOUT+ Just UserTimeout -> Just ((#const IPPROTO_TCP), (#const TCP_USER_TIMEOUT)) #endif #ifdef TCP_CORK Just Cork -> Just ((#const IPPROTO_TCP), (#const TCP_CORK))
Network/Socket/Types.hsc view
@@ -32,6 +32,7 @@ -- * Socket addresses , SockAddr(..)+ , isSupportedSockAddr , HostAddress #if defined(IPV6_SOCKET_SUPPORT) , HostAddress6@@ -801,27 +802,39 @@ type ScopeID = Word32 #endif +-- | The existence of a constructor does not necessarily imply that+-- that socket address type is supported on your system: see+-- 'isSupportedSockAddr'. data SockAddr -- C Names = SockAddrInet PortNumber -- sin_port (network byte order) HostAddress -- sin_addr (ditto)-#if defined(IPV6_SOCKET_SUPPORT) | SockAddrInet6 PortNumber -- sin6_port (network byte order) FlowInfo -- sin6_flowinfo (ditto) HostAddress6 -- sin6_addr (ditto) ScopeID -- sin6_scope_id (ditto)-#endif-#if defined(DOMAIN_SOCKET_SUPPORT) | SockAddrUnix String -- sun_path-#endif-#if defined(AF_CAN) | SockAddrCan Int32 -- can_ifindex (can be get by Network.BSD.ifNameToIndex "can0") -- TODO: Extend this to include transport protocol information-#endif deriving (Eq, Ord, Typeable)++-- | Is the socket address type supported on this system?+isSupportedSockAddr :: SockAddr -> Bool+isSupportedSockAddr addr = case addr of+ SockAddrInet {} -> True+#if defined(IPV6_SOCKET_SUPPORT)+ SockAddrInet6 {} -> True+#endif+#if defined(DOMAIN_SOCKET_SUPPORT)+ SockAddrUnix{} -> True+#endif+#if defined(AF_CAN)+ SockAddrCan{} -> True+#endif+ _ -> False #if defined(WITH_WINSOCK) || defined(cygwin32_HOST_OS) type CSaFamily = (#type unsigned short)
configure.ac view
@@ -35,7 +35,7 @@ dnl ** check for specific header (.h) files that we are interested in AC_CHECK_HEADERS([fcntl.h limits.h stdlib.h sys/types.h unistd.h winsock2.h ws2tcpip.h])-AC_CHECK_HEADERS([arpa/inet.h netdb.h netinet/in.h netinet/tcp.h sys/socket.h sys/uio.h sys/un.h linux/can.h])+AC_CHECK_HEADERS([arpa/inet.h netdb.h netinet/in.h netinet/tcp.h sys/socket.h sys/uio.h sys/un.h linux/can.h linux/tcp.h]) AC_CHECK_HEADERS([net/if.h]) AC_CHECK_FUNCS([readlink symlink if_nametoindex])
include/HsNet.h view
@@ -75,7 +75,9 @@ #ifdef HAVE_SYS_SOCKET_H # include <sys/socket.h> #endif-#ifdef HAVE_NETINET_TCP_H+#ifdef HAVE_LINUX_TCP_H+# include <linux/tcp.h>+#elif HAVE_NETINET_TCP_H # include <netinet/tcp.h> #endif #ifdef HAVE_NETINET_IN_H
network.cabal view
@@ -1,5 +1,5 @@ name: network-version: 2.6.1.0+version: 2.6.2.0 license: BSD3 license-file: LICENSE maintainer: Johan Tibell <johan.tibell@gmail.com>
tests/Simple.hs view
@@ -5,7 +5,7 @@ import Control.Concurrent (ThreadId, forkIO, myThreadId) import Control.Concurrent.MVar (newEmptyMVar, putMVar, takeMVar, readMVar) import qualified Control.Exception as E-import Control.Monad (liftM)+import Control.Monad (liftM, when) import qualified Data.ByteString as S import qualified Data.ByteString.Char8 as C import Data.Maybe (fromJust)@@ -129,6 +129,16 @@ client sock = send sock testMsg +testUserTimeout :: Assertion+testUserTimeout = do+ when (isSupportedSocketOption UserTimeout) $ do+ sock <- socket AF_INET Stream defaultProtocol+ setSocketOption sock UserTimeout 1000+ getSocketOption sock UserTimeout >>= (@=?) 1000+ setSocketOption sock UserTimeout 2000+ getSocketOption sock UserTimeout >>= (@=?) 2000+ sClose sock+ {- testGetPeerCred:: Assertion testGetPeerCred =@@ -237,6 +247,7 @@ , testCase "testOverFlowRecv" testOverFlowRecv , testCase "testRecvFrom" testRecvFrom , testCase "testOverFlowRecvFrom" testOverFlowRecvFrom+ , testCase "testUserTimeout" testUserTimeout -- , testCase "testGetPeerCred" testGetPeerCred -- , testCase "testGetPeerEid" testGetPeerEid #if defined(HAVE_LINUX_CAN_H)