@@ -10,23 +10,24 @@
1010-- Applications that use the TCP transport should use
1111-- 'Network.Socket.withSocketsDo' in their main function for Windows
1212-- compatibility (see "Network.Socket").
13−module Network.Transport.TCP ( -- * Main API
14− createTransport
15− , TCPParameters(..)
16− , defaultTCPParameters
17− -- * Internals (exposed for unit tests)
18− , createTransportExposeInternals
19− , TransportInternals(..)
20− , EndPointId
21− , encodeEndPointAddress
22− , decodeEndPointAddress
23− , ControlHeader(..)
24− , ConnectionRequestResponse(..)
25− , firstNonReservedConnectionId
26− , socketToEndPoint
27− -- * Design notes
28− -- $design
29− ) where
13+module Network.Transport.TCP
14+ ( -- * Main API
15+ createTransport
16+ , TCPParameters(..)
17+ , defaultTCPParameters
18+ -- * Internals (exposed for unit tests)
19+ , createTransportExposeInternals
20+ , TransportInternals(..)
21+ , EndPointId
22+ , encodeEndPointAddress
23+ , decodeEndPointAddress
24+ , ControlHeader(..)
25+ , ConnectionRequestResponse(..)
26+ , firstNonReservedConnectionId
27+ , socketToEndPoint
28+ -- * Design notes
29+ -- $design
30+ ) where
3031
3132import Prelude hiding
3233 ( mapM_
@@ -36,64 +37,69 @@ import Prelude hiding
3637 )
3738
3839import Network.Transport
39−import Network.Transport.TCP.Internal ( forkServer
40− , recvWithLength
41− , recvInt32
42− , tryCloseSocket
43− )
44−import Network.Transport.Internal ( encodeInt32
45− , decodeInt32
46− , prependLength
47− , mapIOException
48− , tryIO
49− , tryToEnum
50− , void
51− , timeoutMaybe
52− , asyncWhenCancelled
53− )
54−import qualified Network.Socket as N ( HostName
55− , ServiceName
56− , Socket
57− , getAddrInfo
58− , socket
59− , addrFamily
60− , addrAddress
61− , SocketType(Stream)
62− , defaultProtocol
63− , setSocketOption
64− , SocketOption(ReuseAddr)
65− , connect
66− , sOMAXCONN
67− , AddrInfo
68− )
40+import Network.Transport.TCP.Internal
41+ ( forkServer
42+ , recvWithLength
43+ , recvInt32
44+ , tryCloseSocket
45+ )
46+import Network.Transport.Internal
47+ ( encodeInt32
48+ , decodeInt32
49+ , prependLength
50+ , mapIOException
51+ , tryIO
52+ , tryToEnum
53+ , void
54+ , timeoutMaybe
55+ , asyncWhenCancelled
56+ )
57+import qualified Network.Socket as N
58+ ( HostName
59+ , ServiceName
60+ , Socket
61+ , getAddrInfo
62+ , socket
63+ , addrFamily
64+ , addrAddress
65+ , SocketType(Stream)
66+ , defaultProtocol
67+ , setSocketOption
68+ , SocketOption(ReuseAddr)
69+ , connect
70+ , sOMAXCONN
71+ , AddrInfo
72+ )
6973import Network.Socket.ByteString (sendMany)
7074import Control.Concurrent (forkIO, ThreadId, killThread, myThreadId)
7175import Control.Concurrent.Chan (Chan, newChan, readChan, writeChan)
72−import Control.Concurrent.MVar ( MVar
73− , newMVar
74− , modifyMVar
75− , modifyMVar_
76− , readMVar
77− , takeMVar
78− , putMVar
79− , newEmptyMVar
80− , withMVar
81− )
76+import Control.Concurrent.MVar
77+ ( MVar
78+ , newMVar
79+ , modifyMVar
80+ , modifyMVar_
81+ , readMVar
82+ , takeMVar
83+ , putMVar
84+ , newEmptyMVar
85+ , withMVar
86+ )
8287import Control.Category ((>>>))
8388import Control.Applicative ((<$>))
8489import Control.Monad (when, unless)
85−import Control.Exception ( IOException
86− , SomeException
87− , AsyncException
88− , handle
89− , throw
90− , throwIO
91− , try
92− , bracketOnError
93− , mask
94− , onException
95− , fromException
96− )
90+import Control.Exception
91+ ( IOException
92+ , SomeException
93+ , AsyncException
94+ , handle
95+ , throw
96+ , throwIO
97+ , try
98+ , bracketOnError
99+ , mask
100+ , onException
101+ , fromException
102+ )
97103import Data.IORef (IORef, newIORef, writeIORef, readIORef)
98104import Data.ByteString (ByteString)
99105import qualified Data.ByteString as BS (concat)
@@ -102,14 +108,15 @@ import Data.Int (Int32)
102108import Data.IntMap (IntMap)
103109import qualified Data.IntMap as IntMap (empty)
104110import Data.IntSet (IntSet)
105−import qualified Data.IntSet as IntSet ( empty
106− , insert
107− , elems
108− , singleton
109− , null
110− , delete
111− , member
112− )
111+import qualified Data.IntSet as IntSet
112+ ( empty
113+ , insert
114+ , elems
115+ , singleton
116+ , null
117+ , delete
118+ , member
119+ )
113120import Data.Map (Map)
114121import qualified Data.Map as Map (empty)
115122import Data.Accessor (Accessor, accessor, (^.), (^=), (^:))