@@ -9,19 +9,18 @@ import Control.Concurrent (forkIO)
9import Control.Concurrent.Chan
9import Control.Concurrent.Chan
10import Control.Concurrent.MVar
10import Control.Concurrent.MVar
11import Control.Monad (forever, unless)
11import Control.Monad (forever, unless)
12−import Data.ByteString.Char8 (ByteString)
12+import Data.ByteString.Lazy.Char8 (ByteString)
13import Data.IntMap (IntMap)
13import Data.IntMap (IntMap)
15import Network.Socket
14import Network.Socket
16import Safe
15import Safe
18−import qualified Data.ByteString.Char8 as BS
17+import qualified Data.ByteString.Lazy.Char8 as BS
19import qualified Data.IntMap as IntMap
18import qualified Data.IntMap as IntMap
20import qualified Network.Socket as N
19import qualified Network.Socket as N
21−import qualified Network.Socket.ByteString as NBS
20+import qualified Network.Socket.ByteString.Lazy as NBS
23−type Chans = MVar (Int, IntMap (Chan ByteString))
23+type Chans = MVar (ChanId, IntMap (Chan ByteString))
26-- | This deals with several different configuration properties:
25-- | This deals with several different configuration properties:
27-- * Buffer size, specified in Hints
26-- * Buffer size, specified in Hints
@@ -56,7 +55,7 @@ mkTransport (TCPConfig _hints host service) = withSocketsDo $ do
56 chan <- newChan
55 chan <- newChan
57 putMVar channels (chanId + 1, IntMap.insert chanId chan chanMap)
56 putMVar channels (chanId + 1, IntMap.insert chanId chan chanMap)
58 return (mkSourceAddr host service chanId, mkTargetEnd chan)
57 return (mkSourceAddr host service chanId, mkTargetEnd chan)
59− , newMulticastWith = undefined
58+ , newMulticastWith = error "newMulticastWith: not defined"
60 , deserialize = \bs ->
59 , deserialize = \bs ->
61 case readMay . BS.unpack $ bs of
60 case readMay . BS.unpack $ bs of
62 Nothing -> error "deserialize: cannot parse"
61 Nothing -> error "deserialize: cannot parse"
@@ -80,8 +79,8 @@ mkTransport (TCPConfig _hints host service) = withSocketsDo $ do
80 setSocketOption sock ReuseAddr 1
79 setSocketOption sock ReuseAddr 1
81 N.connect sock (addrAddress serverAddr)
80 N.connect sock (addrAddress serverAddr)
82 NBS.sendAll sock $ BS.pack . show $ chanId
81 NBS.sendAll sock $ BS.pack . show $ chanId
83− return $ SourceEnd
82+ return SourceEnd
84− { Network.Transport.send = \bss -> NBS.sendMany sock bss
83+ { Network.Transport.send = mapM_ (NBS.send sock)
87 mkTargetEnd :: Chan ByteString -> TargetEnd
86 mkTargetEnd :: Chan ByteString -> TargetEnd