Hello community, here is the log from the commit of package ghc-network for openSUSE:Factory checked in at 2017-06-22 10:38:18 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/ghc-network (Old) and /work/SRC/openSUSE:Factory/.ghc-network.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "ghc-network" Thu Jun 22 10:38:18 2017 rev:13 rq:504087 version:2.6.3.2 Changes: -------- --- /work/SRC/openSUSE:Factory/ghc-network/ghc-network.changes 2016-09-05 21:20:25.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.ghc-network.new/ghc-network.changes 2017-06-22 10:38:19.695088625 +0200 @@ -1,0 +2,5 @@ +Thu Jun 8 11:08:22 UTC 2017 - psim...@suse.com + +- Update to version 2.6.3.2 revision 1. + +------------------------------------------------------------------- Old: ---- network-2.6.3.1.tar.gz New: ---- network-2.6.3.2.tar.gz network.cabal ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ ghc-network.spec ++++++ --- /var/tmp/diff_new_pack.cb1nzV/_old 2017-06-22 10:38:20.554967399 +0200 +++ /var/tmp/diff_new_pack.cb1nzV/_new 2017-06-22 10:38:20.558966834 +0200 @@ -1,7 +1,7 @@ # # spec file for package ghc-network # -# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -19,13 +19,14 @@ %global pkg_name network %bcond_with tests Name: ghc-%{pkg_name} -Version: 2.6.3.1 +Version: 2.6.3.2 Release: 0 Summary: Low-level networking interface License: BSD-3-Clause Group: Development/Languages/Other Url: https://hackage.haskell.org/package/%{pkg_name} Source0: https://hackage.haskell.org/package/%{pkg_name}-%{version}/%{pkg_name}-%{version}.tar.gz +Source1: https://hackage.haskell.org/package/%{pkg_name}-%{version}/revision/1.cabal#/%{pkg_name}.cabal BuildRequires: ghc-Cabal-devel BuildRequires: ghc-bytestring-devel BuildRequires: ghc-rpm-macros @@ -65,6 +66,7 @@ %prep %setup -q -n %{pkg_name}-%{version} +cp -p %{SOURCE1} %{pkg_name}.cabal %build %ghc_lib_build ++++++ network-2.6.3.1.tar.gz -> network-2.6.3.2.tar.gz ++++++ ++++ 1940 lines of diff (skipped) ++++ retrying with extended exclude list diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/network-2.6.3.1/CHANGELOG.md new/network-2.6.3.2/CHANGELOG.md --- old/network-2.6.3.1/CHANGELOG.md 2016-07-31 05:47:24.000000000 +0200 +++ new/network-2.6.3.2/CHANGELOG.md 2017-05-30 22:10:33.000000000 +0200 @@ -1,3 +1,29 @@ +## Version 2.6.3.2 + + * Zero memory of `sockaddr_un` if abstract socket + [#220](https://github.com/haskell/network/pull/220) + + * Improving error messages + [#232](https://github.com/haskell/network/pull/232) + + * Allow non-blocking file descriptors via `setNonBlockIfNeeded` + [#242](https://github.com/haskell/network/pull/242) + + * Update config.{guess,sub} to latest version + [#244](https://github.com/haskell/network/pull/244) + + * Rename `my_inet_ntoa` to avoid symbol conflicts + [#228](https://github.com/haskell/network/pull/228) + + * Test infrastructure improvements + [#219](https://github.com/haskell/network/pull/219) + [#217](https://github.com/haskell/network/pull/217) + [#218](https://github.com/haskell/network/pull/218) + + * House keeping and cleanup + [#238](https://github.com/haskell/network/pull/238) + [#237](https://github.com/haskell/network/pull/237) + ## Version 2.6.3.1 * Reverse breaking exception change in `Network.Socket.ByteString.recv` diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/network-2.6.3.1/Network/BSD.hsc new/network-2.6.3.2/Network/BSD.hsc --- old/network-2.6.3.1/Network/BSD.hsc 2016-07-31 05:47:24.000000000 +0200 +++ new/network-2.6.3.2/Network/BSD.hsc 2017-05-30 22:10:33.000000000 +0200 @@ -168,7 +168,7 @@ serviceProtocol = s_proto }) - poke _p = error "Storable.poke(BSD.ServiceEntry) not implemented" + poke = throwUnsupportedOperationPoke "ServiceEntry" -- | Get service by name. @@ -178,7 +178,7 @@ getServiceByName name proto = withLock $ do withCString name $ \ cstr_name -> do withCString proto $ \ cstr_proto -> do - throwNoSuchThingIfNull "getServiceByName" "no such service entry" + throwNoSuchThingIfNull "Network.BSD.getServiceByName" "no such service entry" $ c_getservbyname cstr_name cstr_proto >>= peek @@ -189,7 +189,7 @@ getServiceByPort :: PortNumber -> ProtocolName -> IO ServiceEntry getServiceByPort port proto = withLock $ do withCString proto $ \ cstr_proto -> do - throwNoSuchThingIfNull "getServiceByPort" "no such service entry" + throwNoSuchThingIfNull "Network.BSD.getServiceByPort" "no such service entry" $ c_getservbyport (fromIntegral port) cstr_proto >>= peek @@ -205,7 +205,7 @@ #if !defined(mingw32_HOST_OS) getServiceEntry :: IO ServiceEntry getServiceEntry = withLock $ do - throwNoSuchThingIfNull "getServiceEntry" "no such service entry" + throwNoSuchThingIfNull "Network.BSD.getServiceEntry" "no such service entry" $ c_getservent >>= peek @@ -270,12 +270,13 @@ protoNumber = p_proto }) - poke _p = error "Storable.poke(BSD.ProtocolEntry) not implemented" + poke = throwUnsupportedOperationPoke "ProtocolEntry" + getProtocolByName :: ProtocolName -> IO ProtocolEntry getProtocolByName name = withLock $ do withCString name $ \ name_cstr -> do - throwNoSuchThingIfNull "getProtocolByName" ("no such protocol name: " ++ name) + throwNoSuchThingIfNull "Network.BSD.getProtocolByName" ("no such protocol name: " ++ name) $ c_getprotobyname name_cstr >>= peek @@ -285,7 +286,7 @@ getProtocolByNumber :: ProtocolNumber -> IO ProtocolEntry getProtocolByNumber num = withLock $ do - throwNoSuchThingIfNull "getProtocolByNumber" ("no such protocol number: " ++ show num) + throwNoSuchThingIfNull "Network.BSD.getProtocolByNumber" ("no such protocol number: " ++ show num) $ c_getprotobynumber (fromIntegral num) >>= peek @@ -301,7 +302,7 @@ #if !defined(mingw32_HOST_OS) getProtocolEntry :: IO ProtocolEntry -- Next Protocol Entry from DB getProtocolEntry = withLock $ do - ent <- throwNoSuchThingIfNull "getProtocolEntry" "no such protocol entry" + ent <- throwNoSuchThingIfNull "Network.BSD.getProtocolEntry" "no such protocol entry" $ c_getprotoent peek ent @@ -359,14 +360,14 @@ hostAddresses = h_addr_list }) - poke _p = error "Storable.poke(BSD.ServiceEntry) not implemented" + poke = throwUnsupportedOperationPoke "HostEntry" -- convenience function: hostAddress :: HostEntry -> HostAddress hostAddress (HostEntry nm _ _ ls) = case ls of - [] -> error ("BSD.hostAddress: empty network address list for " ++ nm) + [] -> error $ "Network.BSD.hostAddress: empty network address list for " ++ nm (x:_) -> x -- getHostByName must use the same lock as the *hostent functions @@ -376,7 +377,7 @@ getHostByName :: HostName -> IO HostEntry getHostByName name = withLock $ do withCString name $ \ name_cstr -> do - ent <- throwNoSuchThingIfNull "getHostByName" "no such host entry" + ent <- throwNoSuchThingIfNull "Network.BSD.getHostByName" "no such host entry" $ c_gethostbyname name_cstr peek ent @@ -390,7 +391,7 @@ getHostByAddr :: Family -> HostAddress -> IO HostEntry getHostByAddr family addr = do with addr $ \ ptr_addr -> withLock $ do - throwNoSuchThingIfNull "getHostByAddr" "no such host entry" + throwNoSuchThingIfNull "Network.BSD.getHostByAddr" "no such host entry" $ c_gethostbyaddr ptr_addr (fromIntegral (sizeOf addr)) (packFamily family) >>= peek @@ -400,7 +401,7 @@ #if defined(HAVE_GETHOSTENT) && !defined(mingw32_HOST_OS) getHostEntry :: IO HostEntry getHostEntry = withLock $ do - throwNoSuchThingIfNull "getHostEntry" "unable to retrieve host entry" + throwNoSuchThingIfNull "Network.BSD.getHostEntry" "unable to retrieve host entry" $ c_gethostent >>= peek @@ -460,14 +461,14 @@ networkAddress = n_net }) - poke _p = error "Storable.poke(BSD.NetEntry) not implemented" + poke = throwUnsupportedOperationPoke "NetworkEntry" #if !defined(mingw32_HOST_OS) getNetworkByName :: NetworkName -> IO NetworkEntry getNetworkByName name = withLock $ do withCString name $ \ name_cstr -> do - throwNoSuchThingIfNull "getNetworkByName" "no such network entry" + throwNoSuchThingIfNull "Network.BSD.getNetworkByName" "no such network entry" $ c_getnetbyname name_cstr >>= peek @@ -476,7 +477,7 @@ getNetworkByAddr :: NetworkAddr -> Family -> IO NetworkEntry getNetworkByAddr addr family = withLock $ do - throwNoSuchThingIfNull "getNetworkByAddr" "no such network entry" + throwNoSuchThingIfNull "Network.BSD.getNetworkByAddr" "no such network entry" $ c_getnetbyaddr addr (packFamily family) >>= peek @@ -485,7 +486,7 @@ getNetworkEntry :: IO NetworkEntry getNetworkEntry = withLock $ do - throwNoSuchThingIfNull "getNetworkEntry" "no more network entries" + throwNoSuchThingIfNull "Network.BSD.getNetworkEntry" "no more network entries" $ c_getnetent >>= peek @@ -549,7 +550,7 @@ getHostName = do let size = 256 allocaArray0 size $ \ cstr -> do - throwSocketErrorIfMinus1_ "getHostName" $ c_gethostname cstr (fromIntegral size) + throwSocketErrorIfMinus1_ "Network.BSD.getHostName" $ c_gethostname cstr (fromIntegral size) peekCString cstr foreign import CALLCONV unsafe "gethostname" @@ -577,3 +578,12 @@ if (ptr == nullPtr) then ioError (ioeSetErrorString (mkIOError NoSuchThing loc Nothing Nothing) desc) else return ptr + +throwUnsupportedOperationPoke :: String -> Ptr a -> a -> IO () +throwUnsupportedOperationPoke typ _ _ = + ioError $ ioeSetErrorString ioe "Operation not implemented" + where + ioe = mkIOError UnsupportedOperation + ("Network.BSD: instance Storable " ++ typ ++ ": poke") + Nothing + Nothing diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/network-2.6.3.1/Network/Socket/ByteString.hsc new/network-2.6.3.2/Network/Socket/ByteString.hsc --- old/network-2.6.3.1/Network/Socket/ByteString.hsc 2016-07-31 05:47:24.000000000 +0200 +++ new/network-2.6.3.2/Network/Socket/ByteString.hsc 2017-05-30 22:10:33.000000000 +0200 @@ -43,14 +43,15 @@ -- $example ) where +import Control.Exception (catch, throwIO) import Control.Monad (when) import Data.ByteString (ByteString) import Data.ByteString.Internal (createAndTrim) import Data.ByteString.Unsafe (unsafeUseAsCStringLen) -import Data.Word (Word8) import Foreign.Marshal.Alloc (allocaBytes) -import Foreign.Ptr (Ptr, castPtr) -import Network.Socket (sendBuf, sendBufTo, recvBufFrom) +import Foreign.Ptr (castPtr) +import Network.Socket (sendBuf, sendBufTo, recvBuf, recvBufFrom) +import System.IO.Error (isEOFError) import qualified Data.ByteString as B @@ -62,20 +63,11 @@ import Control.Monad (liftM, zipWithM_) import Foreign.Marshal.Array (allocaArray) import Foreign.Marshal.Utils (with) -import Foreign.Ptr (plusPtr) +import Foreign.Ptr (Ptr, plusPtr) import Foreign.Storable (Storable(..)) -import Foreign.C.Types (CChar, CSize(..), CInt(..)) import Network.Socket.ByteString.IOVec (IOVec(..)) import Network.Socket.ByteString.MsgHdr (MsgHdr(..)) - -#else -import GHC.IO.FD (FD(..), readRawBufferPtr) -#endif - -#if !defined(mingw32_HOST_OS) -foreign import CALLCONV unsafe "recv" - c_recv :: CInt -> Ptr CChar -> CSize -> CInt -> IO CInt #endif -- ---------------------------------------------------------------------------- @@ -175,7 +167,7 @@ where sendManyInner = liftM fromIntegral . withIOVec cs $ \(iovsPtr, iovsLen) -> - throwSocketErrorWaitWrite sock "writev" $ + throwSocketErrorWaitWrite sock "Network.Socket.ByteString.sendMany" $ c_writev (fromIntegral fd) iovsPtr (fromIntegral (min iovsLen (#const IOV_MAX))) #else @@ -206,7 +198,7 @@ addrPtr (fromIntegral addrSize) iovsPtr (fromIntegral iovsLen) with msgHdr $ \msgHdrPtr -> - throwSocketErrorWaitWrite sock "sendmsg" $ + throwSocketErrorWaitWrite sock "Network.Socket.ByteString.sendManyTo" $ c_sendmsg (fromIntegral fd) msgHdrPtr 0 #else sendManyTo sock cs = sendAllTo sock (B.concat cs) @@ -233,20 +225,10 @@ -> IO ByteString -- ^ Data received recv sock nbytes | nbytes < 0 = ioError (mkInvalidRecvArgError "Network.Socket.ByteString.recv") - | otherwise = createAndTrim nbytes $ recvInner sock nbytes - -recvInner :: Socket -> Int -> Ptr Word8 -> IO Int -recvInner sock nbytes ptr = - fmap fromIntegral $ -#if defined(mingw32_HOST_OS) - throwSocketErrorIfMinus1Retry "Network.Socket.recvBuf" $ - readRawBufferPtr "Network.Socket.ByteString.recv" (FD s 1) ptr 0 (fromIntegral nbytes) -#else - throwSocketErrorWaitRead sock "recv" $ - c_recv s (castPtr ptr) (fromIntegral nbytes) 0 -#endif - where - s = sockFd sock + | otherwise = createAndTrim nbytes $ \ptr -> + catch + (recvBuf sock ptr nbytes) + (\e -> if isEOFError e then return 0 else throwIO e) -- | Receive data from the socket. The socket need not be in a -- connected state. Returns @(bytes, address)@ where @bytes@ is a diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/network-2.6.3.1/Network/Socket/Internal.hsc new/network-2.6.3.2/Network/Socket/Internal.hsc --- old/network-2.6.3.1/Network/Socket/Internal.hsc 2016-07-31 05:47:24.000000000 +0200 +++ new/network-2.6.3.2/Network/Socket/Internal.hsc 2017-05-30 22:10:33.000000000 +0200 @@ -266,7 +266,8 @@ -- Use a CAF to make forcing it do initialisation once, but subsequent forces will be cheap withSocketsInit = unsafePerformIO $ do x <- initWinSock - when (x /= 0) $ ioError $ userError "Failed to initialise WinSock" + when (x /= 0) $ ioError $ + userError "Network.Socket.Internal.withSocketsDo: Failed to initialise WinSock" foreign import ccall unsafe "initWinSock" initWinSock :: IO Int diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/network-2.6.3.1/Network/Socket/Types.hsc new/network-2.6.3.2/Network/Socket/Types.hsc --- old/network-2.6.3.1/Network/Socket/Types.hsc 2016-07-31 05:47:24.000000000 +0200 +++ new/network-2.6.3.2/Network/Socket/Types.hsc 2017-05-30 22:10:33.000000000 +0200 @@ -59,7 +59,6 @@ ) where import Control.Concurrent.MVar -import Control.Exception (throwIO) import Control.Monad import Data.Bits import Data.Maybe @@ -82,7 +81,8 @@ -- * Status flag -- -- If you are calling the 'MkSocket' constructor directly you should ensure --- you have called 'Network.withSocketsDo'. +-- you have called 'Network.withSocketsDo' and that the file descriptor is +-- in non-blocking mode. See 'Network.Socket.setNonBlockIfNeeded'. data Socket = MkSocket CInt -- File Descriptor @@ -724,8 +724,9 @@ #ifdef AF_CAN (#const AF_CAN) -> AF_CAN #endif - unknown -> error ("Network.Socket.unpackFamily: unknown address " ++ - "family " ++ show unknown) + unknown -> error $ + "Network.Socket.Types.unpackFamily: unknown address family: " ++ + show unknown ------------------------------------------------------------------------ -- Port Numbers @@ -892,8 +893,9 @@ #if defined(CAN_SOCKET_SUPPORT) sizeOfSockAddrByFamily AF_CAN = #const sizeof(struct sockaddr_can) #endif -sizeOfSockAddrByFamily family = - error $ "sizeOfSockAddrByFamily: " ++ show family ++ " not supported." +sizeOfSockAddrByFamily family = error $ + "Network.Socket.Types.sizeOfSockAddrByFamily: address family '" ++ + show family ++ "' not supported." -- | Use a 'SockAddr' with a function requiring a pointer to a -- 'SockAddr' and the length of that 'SockAddr'. @@ -922,6 +924,10 @@ pokeSockAddr p (SockAddrUnix path) = do #if defined(darwin_HOST_OS) zeroMemory p (#const sizeof(struct sockaddr_un)) +#else + case path of + ('\0':_) -> zeroMemory p (#const sizeof(struct sockaddr_un)) + _ -> return () #endif #if defined(HAVE_STRUCT_SOCKADDR_SA_LEN) (#poke struct sockaddr_un, sun_len) p ((#const sizeof(struct sockaddr_un)) :: Word8) @@ -990,7 +996,9 @@ ifidx <- (#peek struct sockaddr_can, can_ifindex) p return (SockAddrCan ifidx) #endif - _ -> throwIO $ userError $ "peekSockAddr: " ++ show family ++ " not supported on this platform." + _ -> ioError $ userError $ + "Network.Socket.Types.peekSockAddr: address family '" ++ + show family ++ "' not supported." ------------------------------------------------------------------------ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/network-2.6.3.1/Network/Socket.hsc new/network-2.6.3.2/Network/Socket.hsc --- old/network-2.6.3.1/Network/Socket.hsc 2016-07-31 05:47:24.000000000 +0200 +++ new/network-2.6.3.2/Network/Socket.hsc 2017-05-30 22:10:33.000000000 +0200 @@ -160,6 +160,7 @@ -- in case you ever want to get at the underlying file descriptor.. , fdSocket , mkSocket + , setNonBlockIfNeeded -- * Deprecated aliases -- $deprecated-aliases @@ -262,6 +263,10 @@ FD{fdFD = fd,fdIsSocket_ = 1} #endif +-- | Smart constructor for constructing a 'Socket'. It should only be +-- called once for every new file descriptor. The caller must make +-- sure that the socket is in non-blocking mode. See +-- 'setNonBlockIfNeeded'. mkSocket :: CInt -> Family -> SocketType @@ -339,7 +344,7 @@ -> IO Socket -- Unconnected Socket socket family stype protocol = do c_stype <- packSocketTypeOrThrow "socket" stype - fd <- throwSocketErrorIfMinus1Retry "socket" $ + fd <- throwSocketErrorIfMinus1Retry "Network.Socket.socket" $ c_socket (packFamily family) c_stype protocol setNonBlockIfNeeded fd socket_status <- newMVar NotConnected @@ -372,7 +377,7 @@ socketPair family stype protocol = do allocaBytes (2 * sizeOf (1 :: CInt)) $ \ fdArr -> do c_stype <- packSocketTypeOrThrow "socketPair" stype - _rc <- throwSocketErrorIfMinus1Retry "socketpair" $ + _rc <- throwSocketErrorIfMinus1Retry "Network.Socket.socketpair" $ c_socketpair (packFamily family) c_stype protocol fdArr [fd1,fd2] <- peekArray 2 fdArr s1 <- mkNonBlockingSocket fd1 @@ -390,6 +395,9 @@ #endif -- | Set the socket to nonblocking, if applicable to this platform. +-- +-- Depending on the platform this is required when using sockets from file +-- descriptors that are passed in through 'recvFd' or other means. setNonBlockIfNeeded :: CInt -> IO () setNonBlockIfNeeded fd = System.Posix.Internals.setNonBlockingFD fd True @@ -409,11 +417,12 @@ modifyMVar_ socketStatus $ \ status -> do if status /= NotConnected then - ioError (userError ("bind: can't peform bind on socket in status " ++ - show status)) + ioError $ userError $ + "Network.Socket.bind: can't bind to socket with status " ++ show status else do withSockAddr addr $ \p_addr sz -> do - _status <- throwSocketErrorIfMinus1Retry "bind" $ c_bind s p_addr (fromIntegral sz) + _status <- throwSocketErrorIfMinus1Retry "Network.Socket.bind" $ + c_bind s p_addr (fromIntegral sz) return Bound ----------------------------------------------------------------------------- @@ -427,8 +436,8 @@ modifyMVar_ socketStatus $ \currentStatus -> do if currentStatus /= NotConnected && currentStatus /= Bound then - ioError (userError ("connect: can't peform connect on socket in status " ++ - show currentStatus)) + ioError $ userError $ + errLoc ++ ": can't connect to socket with status " ++ show currentStatus else do withSockAddr addr $ \p_addr sz -> do @@ -442,9 +451,9 @@ _ | err == eINTR -> connectLoop _ | err == eINPROGRESS -> connectBlocked -- _ | err == eAGAIN -> connectBlocked - _otherwise -> throwSocketError "connect" + _otherwise -> throwSocketError errLoc #else - throwSocketError "connect" + throwSocketError errLoc #endif else return () @@ -453,10 +462,12 @@ err <- getSocketOption sock SoError if (err == 0) then return () - else throwSocketErrorCode "connect" (fromIntegral err) + else throwSocketErrorCode errLoc (fromIntegral err) connectLoop return Connected + where + errLoc = "Network.Socket.connect: " ++ show sock ----------------------------------------------------------------------------- -- Listen @@ -471,10 +482,11 @@ modifyMVar_ socketStatus $ \ status -> do if status /= Bound then - ioError (userError ("listen: can't peform listen on socket in status " ++ - show status)) + ioError $ userError $ + "Network.Socket.listen: can't listen on socket with status " ++ show status else do - throwSocketErrorIfMinus1Retry_ "listen" (c_listen s (fromIntegral backlog)) + throwSocketErrorIfMinus1Retry_ "Network.Socket.listen" $ + c_listen s (fromIntegral backlog) return Listening ----------------------------------------------------------------------------- @@ -500,8 +512,10 @@ okay <- isAcceptable sock if not okay then - ioError (userError ("accept: can't perform accept on socket (" ++ (show (family,stype,protocol)) ++") in status " ++ - show currentStatus)) + ioError $ userError $ + "Network.Socket.accept: can't accept socket (" ++ + show (family, stype, protocol) ++ ") with status " ++ + show currentStatus else do let sz = sizeOfSockAddrByFamily family allocaBytes sz $ \ sockaddr -> do @@ -522,11 +536,11 @@ #else with (fromIntegral sz) $ \ ptr_len -> do # ifdef HAVE_ACCEPT4 - new_sock <- throwSocketErrorIfMinus1RetryMayBlock "accept" + new_sock <- throwSocketErrorIfMinus1RetryMayBlock "Network.Socket.accept" (threadWaitRead (fromIntegral s)) (c_accept4 s sockaddr ptr_len (#const SOCK_NONBLOCK)) # else - new_sock <- throwSocketErrorWaitRead sock "accept" + new_sock <- throwSocketErrorWaitRead sock "Network.Socket.accept" (c_accept s sockaddr ptr_len) setNonBlockIfNeeded new_sock # endif /* HAVE_ACCEPT4 */ @@ -547,7 +561,7 @@ #endif ----------------------------------------------------------------------------- --- ** Sending and reciving data +-- ** Sending and receiving data -- $sendrecv -- @@ -587,7 +601,7 @@ sendBufTo sock@(MkSocket s _family _stype _protocol _status) ptr nbytes addr = do withSockAddr addr $ \p_addr sz -> do liftM fromIntegral $ - throwSocketErrorWaitWrite sock "sendTo" $ + throwSocketErrorWaitWrite sock "Network.Socket.sendTo" $ c_sendto s ptr (fromIntegral $ nbytes) 0{-flags-} p_addr (fromIntegral sz) @@ -622,7 +636,7 @@ withNewSockAddr family $ \ptr_addr sz -> do alloca $ \ptr_len -> do poke ptr_len (fromIntegral sz) - len <- throwSocketErrorWaitRead sock "recvFrom" $ + len <- throwSocketErrorWaitRead sock "Network.Socket.recvFrom" $ c_recvfrom s ptr (fromIntegral nbytes) 0{-flags-} ptr_addr ptr_len let len' = fromIntegral len @@ -678,7 +692,7 @@ 0 (fromIntegral len) #else - throwSocketErrorWaitWrite sock "sendBuf" $ + throwSocketErrorWaitWrite sock "Network.Socket.sendBuf" $ c_send s str (fromIntegral len) 0{-flags-} #endif @@ -732,7 +746,7 @@ readRawBufferPtr "Network.Socket.recvBuf" (socket2FD sock) ptr 0 (fromIntegral nbytes) #else - throwSocketErrorWaitRead sock "recvBuf" $ + throwSocketErrorWaitRead sock "Network.Socket.recvBuf" $ c_recv s (castPtr ptr) (fromIntegral nbytes) 0{-flags-} #endif let len' = fromIntegral len @@ -759,7 +773,9 @@ return port #endif socketPort (MkSocket _ family _ _ _) = - ioError (userError ("socketPort: not supported for Family " ++ show family)) + ioError $ userError $ + "Network.Socket.socketPort: address family '" ++ show family ++ + "' not supported." -- --------------------------------------------------------------------------- @@ -775,7 +791,8 @@ getPeerName (MkSocket s family _ _ _) = do withNewSockAddr family $ \ptr sz -> do with (fromIntegral sz) $ \int_star -> do - throwSocketErrorIfMinus1Retry_ "getPeerName" $ c_getpeername s ptr int_star + throwSocketErrorIfMinus1Retry_ "Network.Socket.getPeerName" $ + c_getpeername s ptr int_star _sz <- peek int_star peekSockAddr ptr @@ -783,7 +800,8 @@ getSocketName (MkSocket s family _ _ _) = do withNewSockAddr family $ \ptr sz -> do with (fromIntegral sz) $ \int_star -> do - throwSocketErrorIfMinus1Retry_ "getSocketName" $ c_getsockname s ptr int_star + throwSocketErrorIfMinus1Retry_ "Network.Socket.getSocketName" $ + c_getsockname s ptr int_star peekSockAddr ptr ----------------------------------------------------------------------------- @@ -938,7 +956,7 @@ setSocketOption (MkSocket s _ _ _ _) so v = do (level, opt) <- packSocketOption' "setSocketOption" so with (fromIntegral v) $ \ptr_v -> do - throwSocketErrorIfMinus1_ "setSocketOption" $ + throwSocketErrorIfMinus1_ "Network.Socket.setSocketOption" $ c_setsockopt s level opt ptr_v (fromIntegral (sizeOf (undefined :: CInt))) return () @@ -953,7 +971,7 @@ (level, opt) <- packSocketOption' "getSocketOption" so alloca $ \ptr_v -> with (fromIntegral (sizeOf (undefined :: CInt))) $ \ptr_sz -> do - throwSocketErrorIfMinus1Retry_ "getSocketOption" $ + throwSocketErrorIfMinus1Retry_ "Network.Socket.getSocketOption" $ c_getsockopt s level opt ptr_v ptr_sz fromIntegral `liftM` peek ptr_v @@ -971,7 +989,7 @@ let sz = (#const sizeof(struct ucred)) allocaBytes sz $ \ ptr_cr -> with (fromIntegral sz) $ \ ptr_sz -> do - _ <- ($) throwSocketErrorIfMinus1Retry "getPeerCred" $ + _ <- ($) throwSocketErrorIfMinus1Retry "Network.Socket.getPeerCred" $ c_getsockopt fd (#const SOL_SOCKET) (#const SO_PEERCRED) ptr_cr ptr_sz pid <- (#peek struct ucred, pid) ptr_cr uid <- (#peek struct ucred, uid) ptr_cr @@ -990,7 +1008,7 @@ let fd = fdSocket sock alloca $ \ ptr_uid -> alloca $ \ ptr_gid -> do - throwSocketErrorIfMinus1Retry_ "getPeerEid" $ + throwSocketErrorIfMinus1Retry_ "Network.Socket.getPeerEid" $ c_getpeereid fd ptr_uid ptr_gid uid <- peek ptr_uid gid <- peek ptr_gid @@ -1007,15 +1025,18 @@ -- for transmitting file descriptors, mainly. sendFd :: Socket -> CInt -> IO () sendFd sock outfd = do - _ <- ($) throwSocketErrorWaitWrite sock "sendFd" $ + _ <- ($) throwSocketErrorWaitWrite sock "Network.Socket.sendFd" $ c_sendFd (fdSocket sock) outfd -- Note: If Winsock supported FD-passing, thi would have been -- incorrect (since socket FDs need to be closed via closesocket().) closeFd outfd +-- | Receive a file descriptor over a domain socket. Note that the resulting +-- file descriptor may have to be put into non-blocking mode in order to be +-- used safely. See 'setNonBlockIfNeeded'. recvFd :: Socket -> IO CInt recvFd sock = do - theFd <- throwSocketErrorWaitRead sock "recvFd" $ + theFd <- throwSocketErrorWaitRead sock "Network.Socket.recvFd" $ c_recvFd (fdSocket sock) return theFd @@ -1084,7 +1105,8 @@ -- 'ShutdownBoth', further sends and receives are disallowed. shutdown :: Socket -> ShutdownCmd -> IO () shutdown (MkSocket s _ _ _ _) stype = do - throwSocketErrorIfMinus1Retry_ "shutdown" (c_shutdown s (sdownCmdToInt stype)) + throwSocketErrorIfMinus1Retry_ "Network.Socket.shutdown" $ + c_shutdown s (sdownCmdToInt stype) return () -- ----------------------------------------------------------------------------- @@ -1153,7 +1175,8 @@ withCString ipstr $ \str -> do had <- c_inet_addr str if had == -1 - then ioError (userError ("inet_addr: Malformed address: " ++ ipstr)) + then ioError $ userError $ + "Network.Socket.inet_addr: Malformed address: " ++ ipstr else return had -- network byte order inet_ntoa :: HostAddress -> IO String @@ -1443,7 +1466,7 @@ return ais _ -> do err <- gai_strerror ret ioError (ioeSetErrorString - (mkIOError NoSuchThing "getAddrInfo" Nothing + (mkIOError NoSuchThing "Network.Socket.getAddrInfo" Nothing Nothing) err) -- Leaving out the service and using AI_NUMERICSERV causes a -- segfault on OS X 10.8.2. This code removes AI_NUMERICSERV @@ -1480,7 +1503,7 @@ foreign import ccall safe "gai_strerror" c_gai_strerror :: CInt -> IO CString #else -gai_strerror n = return ("error " ++ show n) +gai_strerror n = ioError $ userError $ "Network.Socket.gai_strerror not supported: " ++ show n #endif withCStringIf :: Bool -> Int -> (CSize -> CString -> IO a) -> IO a @@ -1523,7 +1546,7 @@ return (host, serv) _ -> do err <- gai_strerror ret ioError (ioeSetErrorString - (mkIOError NoSuchThing "getNameInfo" Nothing + (mkIOError NoSuchThing "Network.Socket.getNameInfo" Nothing Nothing) err) foreign import ccall safe "hsnet_getnameinfo" @@ -1542,7 +1565,7 @@ -- --------------------------------------------------------------------------- -- foreign imports from the C library -foreign import ccall unsafe "my_inet_ntoa" +foreign import ccall unsafe "hsnet_inet_ntoa" c_inet_ntoa :: HostAddress -> IO (Ptr CChar) foreign import CALLCONV unsafe "inet_addr" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/network-2.6.3.1/Network.hs new/network-2.6.3.2/Network.hs --- old/network-2.6.3.1/Network.hs 2016-07-31 05:47:24.000000000 +0200 +++ new/network-2.6.3.2/Network.hs 2017-05-30 22:10:33.000000000 +0200 @@ -59,7 +59,6 @@ {-$performance-} ) where -import Control.Exception (throwIO) import Control.Monad (liftM) import Data.Maybe (fromJust) import Network.BSD @@ -98,9 +97,9 @@ #if defined(IPV6_SOCKET_SUPPORT) -- IPv6 and IPv4. -connectTo hostname (Service serv) = connect' hostname serv +connectTo hostname (Service serv) = connect' "Network.connectTo" hostname serv -connectTo hostname (PortNumber port) = connect' hostname (show port) +connectTo hostname (PortNumber port) = connect' "Network.connectTo" hostname (show port) #else -- IPv4 only. @@ -140,15 +139,15 @@ #endif #if defined(IPV6_SOCKET_SUPPORT) -connect' :: HostName -> ServiceName -> IO Handle +connect' :: String -> HostName -> ServiceName -> IO Handle -connect' host serv = do +connect' caller host serv = do proto <- getProtocolNumber "tcp" let hints = defaultHints { addrFlags = [AI_ADDRCONFIG] , addrProtocol = proto , addrSocketType = Stream } addrs <- getAddrInfo (Just hints) (Just host) (Just serv) - firstSuccessful $ map tryToConnect addrs + firstSuccessful caller $ map tryToConnect addrs where tryToConnect addr = bracketOnError @@ -291,14 +290,14 @@ SockAddrInet _ a -> inet_ntoa a SockAddrInet6 _ _ a _ -> return (show a) #if defined(mingw32_HOST_OS) - SockAddrUnix {} -> throwIO $ userError "accept: socket address not supported on this platform." + SockAddrUnix {} -> ioError $ userError "Network.accept: peer socket address 'SockAddrUnix' not supported on this platform." #else SockAddrUnix a -> return a #endif #if defined(CAN_SOCKET_SUPPORT) - SockAddrCan {} -> throwIO $ userError "accept: unsupported for CAN peer." + SockAddrCan {} -> ioError $ userError "Network.accept: peer socket address 'SockAddrCan' not supported." #else - SockAddrCan {} -> throwIO $ userError "accept: socket address not supported on this platform." + SockAddrCan {} -> ioError $ userError "Network.accept: peer socket address 'SockAddrCan' not supported on this platform." #endif handle <- socketToHandle sock' ReadWriteMode let port = case addr of @@ -314,7 +313,8 @@ return (handle, path, -1) #endif accept (MkSocket _ family _ _ _) = - error $ "Sorry, address family " ++ (show family) ++ " is not supported!" + ioError $ userError $ "Network.accept: address family '" ++ + show family ++ "' not supported." -- | Close the socket. Sending data to or receiving data from closed socket @@ -405,14 +405,14 @@ #if defined(IPV6_SOCKET_SUPPORT) SockAddrInet6 port _ _ _ -> return $ PortNumber port #else - SockAddrInet6 {} -> throwIO $ userError "socketPort: socket address not supported on this platform." + SockAddrInet6 {} -> ioError $ userError "Network.socketPort: socket address 'SockAddrInet6' not supported on this platform." #endif #if defined(mingw32_HOST_OS) - SockAddrUnix {} -> throwIO $ userError "socketPort: socket address not supported on this platform." + SockAddrUnix {} -> ioError $ userError "Network.socketPort: socket address 'SockAddrUnix' not supported on this platform." #else SockAddrUnix path -> return $ UnixSocket path #endif - SockAddrCan {} -> throwIO $ userError "socketPort: CAN address not supported." + SockAddrCan {} -> ioError $ userError "Network.socketPort: socket address 'SockAddrCan' not supported." -- --------------------------------------------------------------------------- -- Utils @@ -463,8 +463,8 @@ -- The operations are run outside of the catchIO cleanup handler because -- catchIO masks asynchronous exceptions in the cleanup handler. -- In the case of complete failure, the last exception is actually thrown. -firstSuccessful :: [IO a] -> IO a -firstSuccessful = go Nothing +firstSuccessful :: String -> [IO a] -> IO a +firstSuccessful caller = go Nothing where -- Attempt the next operation, remember exception on failure go _ (p:ps) = @@ -474,5 +474,5 @@ Left e -> go (Just e) ps -- All operations failed, throw error if one exists - go Nothing [] = error "firstSuccessful: empty list" + go Nothing [] = ioError $ userError $ caller ++ ": firstSuccessful: empty list" go (Just e) [] = Exception.throwIO e diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/network-2.6.3.1/README.md new/network-2.6.3.2/README.md --- old/network-2.6.3.1/README.md 2016-07-31 05:47:24.000000000 +0200 +++ new/network-2.6.3.2/README.md 2017-05-30 22:10:33.000000000 +0200 @@ -1,10 +1,19 @@ # [`network`](http://hackage.haskell.org/package/network) [![Build Status](https://travis-ci.org/haskell/network.svg?branch=master)](https://travis-ci.org/haskell/network) [![Build status](https://ci.appveyor.com/api/projects/status/5erq63o4m29bhl57/branch/master?svg=true)](https://ci.appveyor.com/project/eborden/network/branch/master) - - To build this package using Cabal directly from git, you must run `autoreconf` before the usual Cabal build steps (configure/build/install). `autoreconf` is included in the [GNU Autoconf](http://www.gnu.org/software/autoconf/) tools. There is no need to run the `configure` script: the `setup configure` step will do this for you. + +## Support Policy + +### GHC + +`network`'s GHC policy supports 3 [stable](https://downloads.haskell.org/~ghc/8.0.2/docs/html/users_guide/intro.html#ghc-version-numbering-policy) versions. The current stable +version and two previous stable versions are supported. + +### Hugs, JHC, UHC + +`network` does not officially support these compilers. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/network-2.6.3.1/configure.ac new/network-2.6.3.2/configure.ac --- old/network-2.6.3.1/configure.ac 2016-07-31 05:47:24.000000000 +0200 +++ new/network-2.6.3.2/configure.ac 2017-05-30 22:10:33.000000000 +0200 @@ -1,4 +1,4 @@ -AC_INIT([Haskell network package], [2.3.0.14], [librar...@haskell.org], [network]) +AC_INIT([Haskell network package], [2.6.3.1], [librar...@haskell.org], [network]) ac_includes_default="$ac_includes_default #ifdef HAVE_SYS_SOCKET_H diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/network-2.6.3.1/include/HsNet.h new/network-2.6.3.2/include/HsNet.h --- old/network-2.6.3.1/include/HsNet.h 2016-07-31 05:47:24.000000000 +0200 +++ new/network-2.6.3.2/include/HsNet.h 2017-05-30 22:10:33.000000000 +0200 @@ -1,6 +1,6 @@ /* ----------------------------------------------------------------------------- * - * Definitions for package `net' which are visible in Haskell land. + * Definitions for package `network' which are visible in Haskell land. * * ---------------------------------------------------------------------------*/ @@ -118,7 +118,7 @@ #endif /* HAVE_WINSOCK2_H */ INLINE char * -my_inet_ntoa( +hsnet_inet_ntoa( #if defined(HAVE_WINSOCK2_H) u_long addr #elif defined(HAVE_IN_ADDR_T) @@ -129,7 +129,7 @@ unsigned long addr #endif ) -{ +{ struct in_addr a; a.s_addr = addr; return inet_ntoa(a); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/network-2.6.3.1/include/HsNetworkConfig.h new/network-2.6.3.2/include/HsNetworkConfig.h --- old/network-2.6.3.1/include/HsNetworkConfig.h 2016-07-31 05:47:24.000000000 +0200 +++ new/network-2.6.3.2/include/HsNetworkConfig.h 2017-05-30 22:10:33.000000000 +0200 @@ -160,7 +160,7 @@ #define PACKAGE_NAME "Haskell network package" /* Define to the full name and version of this package. */ -#define PACKAGE_STRING "Haskell network package 2.3.0.14" +#define PACKAGE_STRING "Haskell network package 2.6.3.1" /* Define to the one symbol short name of this package. */ #define PACKAGE_TARNAME "network" @@ -169,7 +169,7 @@ #define PACKAGE_URL "" /* Define to the version of this package. */ -#define PACKAGE_VERSION "2.3.0.14" +#define PACKAGE_VERSION "2.6.3.1" /* Define to 1 if you have the ANSI C header files. */ #define STDC_HEADERS 1 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/network-2.6.3.1/network.cabal new/network-2.6.3.2/network.cabal --- old/network-2.6.3.1/network.cabal 2016-07-31 05:47:24.000000000 +0200 +++ new/network-2.6.3.2/network.cabal 2017-05-30 22:10:33.000000000 +0200 @@ -1,5 +1,5 @@ name: network -version: 2.6.3.1 +version: 2.6.3.2 license: BSD3 license-file: LICENSE maintainer: Kazu Yamamoto, Evan Borden @@ -41,7 +41,7 @@ cbits/winSockErr.c homepage: https://github.com/haskell/network bug-reports: https://github.com/haskell/network/issues -tested-with: GHC == 7.0.4, GHC == 7.4.2, GHC == 7.6.3, GHC == 7.8.4, GHC == 7.10.1, GHC == 7.10.2, GHC == 8.0.1 +tested-with: GHC == 7.8.4, GHC == 7.10.1, GHC == 7.10.2, GHC == 8.0.1, GHC == 8.0.2 library exposed-modules: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/network-2.6.3.1/tests/Regression.hs new/network-2.6.3.2/tests/Regression.hs --- old/network-2.6.3.1/tests/Regression.hs 2016-07-31 05:47:24.000000000 +0200 +++ new/network-2.6.3.2/tests/Regression.hs 2017-05-30 22:10:33.000000000 +0200 @@ -9,8 +9,6 @@ import Test.Framework.Providers.HUnit (testCase) import Test.HUnit (assertFailure) -import qualified Regression.Issue215 as Issue215 - ------------------------------------------------------------------------ -- Tests @@ -51,7 +49,6 @@ [ testCase "testGetAddrInfo" testGetAddrInfo , testCase "badRecvShouldThrow" badRecvShouldThrow , testCase "badSendShouldThrow" badSendShouldThrow - , testCase "recvShouldntThrowOnClosedSocket" Issue215.main ] ------------------------------------------------------------------------ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/network-2.6.3.1/tests/Simple.hs new/network-2.6.3.2/tests/Simple.hs --- old/network-2.6.3.1/tests/Simple.hs 2016-07-31 05:47:24.000000000 +0200 +++ new/network-2.6.3.2/tests/Simple.hs 2017-05-30 22:10:33.000000000 +0200 @@ -12,6 +12,7 @@ import Data.Maybe (fromJust) #endif import Network.Socket hiding (recv, recvFrom, send, sendTo) +import qualified Network.Socket (recv) import Network.Socket.ByteString --- To tests for AF_CAN on Linux, you need to bring up a virtual (or real can @@ -30,7 +31,7 @@ #endif import Test.Framework (Test, defaultMain, testGroup) import Test.Framework.Providers.HUnit (testCase) -import Test.HUnit (Assertion, (@=?)) +import Test.HUnit (Assertion, (@=?), assertBool, assertFailure) ------------------------------------------------------------------------ @@ -229,9 +230,35 @@ serverSetup = clientSetup #endif +-- The String version of 'recv' should throw an exception when the remote end +-- has closed the connection, the ByteString version should return an empty +-- ByteString. +testStringEol :: Assertion +testStringEol = tcpTest client close + where client s = do + res <- E.try $ Network.Socket.recv s 4096 + case res of + Left (_ :: IOError) -> return () + Right _ -> assertFailure + "String recv didn't throw an exception on a closed socket" + +testByteStringEol :: Assertion +testByteStringEol = tcpTest client close + where client s = do + res :: Either IOError C.ByteString <- E.try $ recv s 4096 + res @=? Right S.empty + ------------------------------------------------------------------------ -- Conversions of IP addresses +testHtonlNtohl :: Assertion +testHtonlNtohl = do + let addrl = 0xCafeBabe + addrl @=? (htonl . ntohl) addrl + addrl @=? (ntohl . htonl) addrl + assertBool "BE or LE byte order" $ + ntohl addrl `elem` [0xCafeBabe, 0xbebafeca] + testHostAddressToTuple :: Assertion testHostAddressToTuple = do -- Look up a numeric IPv4 host @@ -287,10 +314,13 @@ , testCase "testUserTimeout" testUserTimeout -- , testCase "testGetPeerCred" testGetPeerCred -- , testCase "testGetPeerEid" testGetPeerEid + , testCase "testStringEol" testStringEol + , testCase "testByteStringEol" testByteStringEol #if defined(HAVE_LINUX_CAN_H) , testCase "testCanSend" testCanSend #endif -- conversions of IP addresses + , testCase "testHtonlNtohl" testHtonlNtohl , testCase "testHostAddressToTuple" testHostAddressToTuple , testCase "testHostAddressToTupleInv" testHostAddressToTupleInv #if defined(IPV6_SOCKET_SUPPORT) @@ -314,7 +344,7 @@ case sockAddr of (SockAddrInet port _) -> return port (SockAddrInet6 port _ _ _) -> return port - _ -> error "getPeerPort: only works with IP sockets" + _ -> ioError $ userError "getPeerPort: only works with IP sockets" -- | Establish a connection between client and server and then run -- 'clientAct' and 'serverAct', in different threads. Both actions ++++++ network.cabal ++++++ name: network version: 2.6.3.2 x-revision: 1 license: BSD3 license-file: LICENSE maintainer: Kazu Yamamoto, Evan Borden synopsis: Low-level networking interface description: This package provides a low-level networking interface. . In network-2.6 the @Network.URI@ module was split off into its own package, network-uri-2.6. If you're using the @Network.URI@ module you can automatically get it from the right package by adding this to your .cabal file: . > flag network-uri > description: Get Network.URI from the network-uri package > default: True > > library > -- ... > if flag(network-uri) > build-depends: network-uri >= 2.6, network >= 2.6 > else > build-depends: network-uri < 2.6, network < 2.6 . That is, get the module from either network < 2.6 or from network-uri >= 2.6. category: Network build-type: Configure cabal-version: >=1.8 extra-tmp-files: config.log config.status autom4te.cache network.buildinfo include/HsNetworkConfig.h extra-source-files: README.md CHANGELOG.md examples/*.hs tests/*.hs config.guess config.sub install-sh configure.ac configure network.buildinfo.in include/HsNetworkConfig.h.in include/HsNet.h -- C sources only used on some systems cbits/ancilData.c cbits/asyncAccept.c cbits/initWinSock.c cbits/winSockErr.c homepage: https://github.com/haskell/network bug-reports: https://github.com/haskell/network/issues tested-with: GHC == 7.8.4, GHC == 7.10.1, GHC == 7.10.2, GHC == 8.0.1, GHC == 8.0.2 library exposed-modules: Network Network.BSD Network.Socket Network.Socket.ByteString Network.Socket.ByteString.Lazy Network.Socket.Internal other-modules: Network.Socket.ByteString.Internal Network.Socket.Types if !os(windows) other-modules: Network.Socket.ByteString.IOVec Network.Socket.ByteString.Lazy.Posix Network.Socket.ByteString.MsgHdr if os(windows) other-modules: Network.Socket.ByteString.Lazy.Windows build-depends: base >= 4.6 && < 5, bytestring < 0.11 if !os(windows) build-depends: unix >= 2 extensions: CPP, DeriveDataTypeable, ForeignFunctionInterface, TypeSynonymInstances include-dirs: include includes: HsNet.h install-includes: HsNet.h HsNetworkConfig.h c-sources: cbits/HsNet.c ghc-options: -Wall -fwarn-tabs test-suite simple hs-source-dirs: tests main-is: Simple.hs type: exitcode-stdio-1.0 build-depends: base < 5, bytestring, HUnit, network, test-framework, test-framework-hunit test-suite regression hs-source-dirs: tests main-is: Regression.hs type: exitcode-stdio-1.0 build-depends: base < 5, bytestring, HUnit, network, test-framework, test-framework-hunit -- Some of the bugs only occur in the threaded RTS ghc-options: -Wall -threaded test-suite doctest hs-source-dirs: tests main-is: doctests.hs type: exitcode-stdio-1.0 build-depends: base < 5, doctest >= 0.10.1 ghc-options: -Wall source-repository head type: git location: git://github.com/haskell/network.git