packages feed

network-run 0.1.0 → 0.2.0

raw patch · 4 files changed

+18/−24 lines, 4 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

Network/Run/Core.hs view
@@ -2,30 +2,12 @@ {-# LANGUAGE CPP #-}  module Network.Run.Core (-    runClient-  , resolve+    resolve+  , openSocket   , openServerSocket   ) where -import qualified Control.Exception as E-import Control.Monad (when) import Network.Socket--runClient :: SocketType -> String -> String -> (Socket -> SockAddr -> IO a) -> IO a-runClient socketType host port client = withSocketsDo $ do-    addr <- resolve socketType (Just host) port False-    let sockAddr = addrAddress addr-#if MIN_VERSION_network(3,1,1)-    E.bracket (open addr) (\sock -> gracefulClose sock 5000)-                          (\sock -> client sock sockAddr)-#else-    E.bracket (open addr) close $ \sock -> client sock sockAddr-#endif-  where-    open addr = do-        sock <- openSocket addr-        when (socketType == Stream) $ connect sock $ addrAddress addr-        return sock  resolve :: SocketType -> Maybe HostName -> ServiceName -> Bool -> IO AddrInfo resolve socketType mhost port passive =
Network/Run/TCP.hs view
@@ -16,9 +16,18 @@  -- | Running a TCP client with a connected socket. runTCPClient :: String -> String -> (Socket -> IO a) -> IO a-runTCPClient host port client = runClient Stream host port client'+runTCPClient host port client = withSocketsDo $ do+    addr <- resolve Stream (Just host) port False+#if MIN_VERSION_network(3,1,1)+    E.bracket (open addr) (\sock -> gracefulClose sock 5000) client+#else+    E.bracket (open addr) close client+#endif   where-    client' sock _peer = client sock+    open addr = do+        sock <- openSocket addr+        connect sock $ addrAddress addr+        return sock  -- | Running a TCP server with an accepted socket and its peer name. runTCPServer :: Maybe HostName -> ServiceName -> (Socket -> IO a) -> IO a
Network/Run/UDP.hs view
@@ -14,7 +14,10 @@ --   server's socket address. --   They should be used with 'sendTo'. runUDPClient :: String -> String -> (Socket -> SockAddr -> IO a) -> IO a-runUDPClient = runClient Datagram+runUDPClient host port client = withSocketsDo $ do+    addr <- resolve Datagram (Just host) port False+    let sockAddr = addrAddress addr+    E.bracket (openSocket addr) close $ \sock -> client sock sockAddr  -- | Running a UDP server with an open socket. runUDPServer :: Maybe HostName -> ServiceName -> (Socket -> IO a) -> IO a
network-run.cabal view
@@ -1,5 +1,5 @@ name:                network-run-version:             0.1.0+version:             0.2.0 synopsis:            Simple network runner library description:         Simple functions to run network clients and servers. -- bug-reports: