[Haskell-cafe] Cannot System,Timeout.timeout Network.accept

Daniel Hlynskyi abcz2.uprola at gmail.com
Thu Jun 21 19:58:52 CEST 2012


Hello Cafe.

I cannot accept socket connection with timeout (Windows, GHC 7.4,1).
Consider following code:

> import Network
> import System.Timeout
> main = withSocketsDo $ do
>     print ":: Starting server ..."
>     sock <- listenOn (PortNumber 4010)
>     res <- timeout 1 (accept sock)
>     print "Timed out" -- Never output!
>     sClose sock

Documentation on
http://www.haskell.org/ghc/docs/latest/html/libraries/base/System-Timeout.html
says:"... Standard
I/O functions like ... Network.Socket.accept, ... appear to be blocking,
but they really don't because the runtime system uses scheduling mechanisms
like select(2) to perform asynchronous I/O, so it is possible to interrupt
standard socket I/O or file I/O using this combinator." Neither
Network.accept, nor Network.Socket.accept can be timed out is example above.

Is it bug?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20120621/620f2081/attachment.htm>


More information about the Haskell-Cafe mailing list