@@ -22,8 +22,8 @@ import Network.Transport.Internal.TCP ( forkServer
2222 , sendInt32
2323 )
2424import Network.Transport.Internal ( encodeInt16
25− , maybeToErrorT
26− , maybeTToErrorT
25+ , failWith
26+ , failWithT
2727 )
2828import qualified Network.Socket as N ( HostName
2929 , ServiceName
@@ -95,7 +95,7 @@ handleClient state sock = do
9595 mendpoint <- runMaybeT $ do
9696 ourEndPointId <- recvInt16 sock
9797 theirAddress <- BS.concat <$> recvWithLength sock
98− ourEndPoint <- MaybeT $ (^. endPointAt (fromIntegral ourEndPointId)) <$> readMVar state
98+ ourEndPoint <- MaybeT $ (^. endPointAt ourEndPointId) <$> readMVar state
9999 return (ourEndPoint, EndPointAddress theirAddress)
100100 case mendpoint of
101101 Just ((endPointCh, endPointSt), theirAddress) -> do
@@ -159,9 +159,9 @@ firstNonReservedConnectionId = 1024
159159tcpConnect :: EndPointAddress -> EndPointAddress -> Reliability -> IO (Either (FailedWith ConnectErrorCode) Connection)
160160tcpConnect myAddress theirAddress _ = runErrorT $ do
161161 sock <- socketForEndPoint myAddress theirAddress
162− connId <- maybeTToErrorT undefined $ requestNewConnection sock
162+ connId <- failWithT undefined $ requestNewConnection sock
163163 return Connection { send = runErrorT .
164− maybeTToErrorT (FailedWith SendFailed "Send failed") .
164+ failWithT (FailedWith SendFailed "Send failed") .
165165 sendWithLength sock (Just connId)
166166 , close = N.sClose sock
167167 }
@@ -180,10 +180,10 @@ socketForEndPoint :: EndPointAddress -- ^ Our address
180180 -> EndPointAddress -- ^ Their address
181181 -> ErrorT (FailedWith ConnectErrorCode) IO N.Socket
182182socketForEndPoint (EndPointAddress myAddress) theirAddress = do
183− (host, port, endPointId) <- maybeToErrorT invalidAddress (decodeEndPointAddress theirAddress)
184− sock <- maybeTToErrorT undefined (connectTo host port)
185− endPointBS <- encodeInt16 (fromIntegral endPointId)
186− maybeTToErrorT undefined $ sendWithLength sock (Just endPointBS) [myAddress]
183+ (host, port, endPointId) <- failWith invalidAddress (decodeEndPointAddress theirAddress)
184+ sock <- failWithT undefined (connectTo host port)
185+ endPointBS <- encodeInt16 endPointId
186+ failWithT undefined $ sendWithLength sock (Just endPointBS) [myAddress]
187187 return sock
188188 where
189189 invalidAddress = FailedWith ConnectInvalidAddress "Invalid address"