Simon Marlow wrote:

> > OTOH, the core problem with Network.recvFrom is essentially that it
> > appears to be a misguided attempt to provide a symmetric counterpart
> > to Network.sendTo. While the low-level sendTo/recvFrom functions may
> > be roughly symmetric, at a higher level, the client and server ends of
> > a connection aren't at all symmetric.
> 
> Yes, I'm sure that's the reason for it.  Proposals for a replacement are
> welcome...

What would be the intended purpose of a replacement?

If you want a simpler interface for writing servers, it would probably
look something like:

        doServer :: PortID -> (Handle -> IO ()) -> IO ()
        doServer port handler = do
                s <- listenOn port
                let doIt = do
                        ~(s', _)  <-  Socket.accept s
                        h <- socketToHandle s' ReadWriteMode
                        forkIO $ handler h >> hClose h
                sequence_ $ repeat doIt

Ultimately, you either need to create a separate thread/process per
connection, or manually service multiple connections (select/poll). A
server which processed connections sequentially wouldn't be of much
practical use (and a one-shot server probably wouldn't even be of use
for "toy" programs).

-- 
Glynn Clements <[EMAIL PROTECTED]>
_______________________________________________
Glasgow-haskell-users mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

Reply via email to