Hi Chris,In my application, I'm using Data.Conduit.Network from conduit-extra directly (Data.Streaming.Network from streaming-commons indirectly). The timeout I'm interested in managing is the connection establishment timeout - how long does the connect call wait to establish a connection. I haven't been able to figure out how to control this outside of applying a non-conditional timeout to the connect call (which is a timeout on the lifetime of a connection, not a timeout on the establishment of a connection). Thanks!MarkOn Sat, Oct 14, 2017 at 3:09 AM, Chris Wong <lambda.fairy@gmail.com> wrote:Hi Mark,What networking library are you using?There should be a lower level interface which allows for managing the lifetime of a connection by hand.ChrisOn Oct 14, 2017 15:17, "Mark Fine" <mark.fine@gmail.com> wrote:______________________________I'd like a configurable network connect timeout. Has anyone solved this reasonably?System.Timeout.timeout times out connections, but works on the granularity of the life of the connection. Is there a reasonable way to configure a timeout around just establishing the connection? Maybe something like a conditional timeout that enables an action to disable the timeout once it expires?As a workaround, I'm spinning trying to successfully connect first before trying to connect for real:-- | Try the TCP connection and see if you can connect...--tryTCPClient :: Int -> ClientSettings -> IO ()tryTCPClient microseconds settings = dook <- newIORef Falsevoid $ timeout microseconds $ runTCPClient settings $ const $writeIORef ok Trueok' <- readIORef okunless ok' $tryTCPClient microseconds settings-- | Wrap runTCPClient with a connect timeout.---- Tries the TCP connection first, and the runs the regular runTCPClient.-- Of course, this only enforces a TCP connect timeout on the first connect.-- The second TCP connect has no timeout :(--runTCPClient' :: Int -> ClientSettings -> (AppData -> IO a) -> IO arunTCPClient' microseconds settings action = dotryTCPClient microseconds settingsrunTCPClient settings actionI've also tried running the tryTCPClient in its own thread concurrently with runTCPClient and throwing an exception if it can't connect in microseconds. None of these offer an actual true connection establishment timeout.Has anyone found a way to solve this? Thanks!Mark_________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-caf e
Only members subscribed via the mailman list are allowed to post.