
I am trying to write a toy echo server that can handle multiple connections. I would like to be able to test and see if there are any connections waiting to be accepted on a socket. In C and related languages I would use something like select or poll to be nice to the OS, what would I use with the current haskell libs given that I can't seem to find a function to test if accept would block or not? -mdg -- Our problems are mostly behind us, now all we have to do is fight the solutions.

Mark Goldman wrote:
I am trying to write a toy echo server that can handle multiple connections. I would like to be able to test and see if there are any connections waiting to be accepted on a socket. In C and related languages I would use something like select or poll to be nice to the OS, what would I use with the current haskell libs given that I can't seem to find a function to test if accept would block or not?
-mdg
The wiki page http://haskell.org/haskellwiki/Concurrency_demos/Graceful_exit uses accepting connections as its example. The main idea is use accept (which blocks) in a background thread and which provides the resulting connections to some inter-thread data stream: MVar, MChan, TMVar, TChan, or your own structure. Shutting down a system is usually subtle, and that wiki page concentrates on a trying to create a solution which provides dependable shutdown semantics.

Or you could ignore the problem of shutdown altogether: http://swig.stanford.edu/~candea/papers/crashonly/ On Jan 2, 2007, at 12:20 PM, Chris Kuklewicz wrote:
Mark Goldman wrote:
I am trying to write a toy echo server that can handle multiple connections. I would like to be able to test and see if there are any connections waiting to be accepted on a socket. In C and related languages I would use something like select or poll to be nice to the OS, what would I use with the current haskell libs given that I can't seem to find a function to test if accept would block or not?
-mdg
The wiki page http://haskell.org/haskellwiki/Concurrency_demos/ Graceful_exit uses accepting connections as its example.
The main idea is use accept (which blocks) in a background thread and which provides the resulting connections to some inter-thread data stream: MVar, MChan, TMVar, TChan, or your own structure.
Shutting down a system is usually subtle, and that wiki page concentrates on a trying to create a solution which provides dependable shutdown semantics. _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
participants (3)
-
Chris Kuklewicz
-
Mark Goldman
-
Reilly Hayes