Prior to this patch, the connection timeout was misplaced and
effectively was a connection time limit instead.
{-# LANGUAGE OverloadedStrings #-}
import Network.Transport
import qualified Network.Transport.TCP as TCP
import Control.Concurrent
main = do
let timeout = 1000000
let params = TCP.defaultTCPParameters { TCP.transportConnectTimeout = Just timeout }
Right transport <- TCP.createTransport "127.0.0.1" "7777" ((,) "127.0.0.1") params
Right server <- newEndPoint transport
Right client <- newEndPoint transport
Right conn <- connect client (address server) ReliableOrdered defaultConnectHints
threadDelay (timeout * 2)
-- This ought to be 'Right ()' but the timeout has almost certainly killed the socket
-- by now.
-- err = TransportError SendFailed "user error (recvExact: Socket closed)"
Left err <- send conn ["hello world"]
close conn
closeEndPoint client
closeEndPoint server
closeTransport transport
Prior to this patch, the connection timeout was misplaced and effectively was a connection time limit instead.