@@ -22,8 +22,8 @@ import Network.Transport.Internal.TCP ( forkServer
22 , sendInt32
22 , sendInt32
24import Network.Transport.Internal ( encodeInt16
24import Network.Transport.Internal ( encodeInt16
25− , maybeToErrorT
25+ , failWith
26− , maybeTToErrorT
26+ , failWithT
28import qualified Network.Socket as N ( HostName
28import qualified Network.Socket as N ( HostName
29 , ServiceName
29 , ServiceName
@@ -95,7 +95,7 @@ handleClient state sock = do
95 mendpoint <- runMaybeT $ do
95 mendpoint <- runMaybeT $ do
96 ourEndPointId <- recvInt16 sock
96 ourEndPointId <- recvInt16 sock
97 theirAddress <- BS.concat <$> recvWithLength sock
97 theirAddress <- BS.concat <$> recvWithLength sock
98− ourEndPoint <- MaybeT $ (^. endPointAt (fromIntegral ourEndPointId)) <$> readMVar state
98+ ourEndPoint <- MaybeT $ (^. endPointAt ourEndPointId) <$> readMVar state
99 return (ourEndPoint, EndPointAddress theirAddress)
99 return (ourEndPoint, EndPointAddress theirAddress)
100 case mendpoint of
100 case mendpoint of
101 Just ((endPointCh, endPointSt), theirAddress) -> do
101 Just ((endPointCh, endPointSt), theirAddress) -> do
@@ -159,9 +159,9 @@ firstNonReservedConnectionId = 1024
159tcpConnect :: EndPointAddress -> EndPointAddress -> Reliability -> IO (Either (FailedWith ConnectErrorCode) Connection)
159tcpConnect :: EndPointAddress -> EndPointAddress -> Reliability -> IO (Either (FailedWith ConnectErrorCode) Connection)
160tcpConnect myAddress theirAddress _ = runErrorT $ do
160tcpConnect myAddress theirAddress _ = runErrorT $ do
161 sock <- socketForEndPoint myAddress theirAddress
161 sock <- socketForEndPoint myAddress theirAddress
162− connId <- maybeTToErrorT undefined $ requestNewConnection sock
162+ connId <- failWithT undefined $ requestNewConnection sock
163 return Connection { send = runErrorT .
163 return Connection { send = runErrorT .
164− maybeTToErrorT (FailedWith SendFailed "Send failed") .
164+ failWithT (FailedWith SendFailed "Send failed") .
165 sendWithLength sock (Just connId)
165 sendWithLength sock (Just connId)
166 , close = N.sClose sock
166 , close = N.sClose sock
@@ -180,10 +180,10 @@ socketForEndPoint :: EndPointAddress -- ^ Our address
180 -> EndPointAddress -- ^ Their address
180 -> EndPointAddress -- ^ Their address
181 -> ErrorT (FailedWith ConnectErrorCode) IO N.Socket
181 -> ErrorT (FailedWith ConnectErrorCode) IO N.Socket
182socketForEndPoint (EndPointAddress myAddress) theirAddress = do
182socketForEndPoint (EndPointAddress myAddress) theirAddress = do
183− (host, port, endPointId) <- maybeToErrorT invalidAddress (decodeEndPointAddress theirAddress)
183+ (host, port, endPointId) <- failWith invalidAddress (decodeEndPointAddress theirAddress)
184− sock <- maybeTToErrorT undefined (connectTo host port)
184+ sock <- failWithT undefined (connectTo host port)
185− endPointBS <- encodeInt16 (fromIntegral endPointId)
185+ endPointBS <- encodeInt16 endPointId
186− maybeTToErrorT undefined $ sendWithLength sock (Just endPointBS) [myAddress]
186+ failWithT undefined $ sendWithLength sock (Just endPointBS) [myAddress]
187 return sock
187 return sock
189 invalidAddress = FailedWith ConnectInvalidAddress "Invalid address"
189 invalidAddress = FailedWith ConnectInvalidAddress "Invalid address"