Ticket #7353: timeout.hs

File timeout.hs, 264 bytes (added by joeyadams, 5 years ago)

Simple example of hanging network IO; times out on Linux, but not on Windows.

Line 
1import Network
2import System.Timeout
3
4main = withSocketsDo $ do
5    putStrLn "Connecting to google.com:1234"
6    m <- timeout 5000000 $ connectTo "google.com" (PortNumber 1234)
7    putStrLn $ case m of
8        Nothing -> "Timed out"
9        Just _h -> "Connected"