[Haskell-cafe] Waiting on input with `hWaitForInput' or `threadWaitRead'
Jason Dusek
jason.dusek at gmail.com
Tue Oct 18 19:24:10 CEST 2011
2011/10/18 Jason Dusek <jason.dusek at gmail.com>:
> 2011/10/18 Ertugrul Soeylemez <es at ertes.de>:
> > A proxy server acts a lot like an echo server. The difference is that
> > usually before the actual proxying starts you have a negotiation phase,
> > and instead of echoing back to the same socket, you just write it to a
> > different one. Here is an (untested) example:
> >
> > (clientH, clientHost, clientPort) <- accept serverSock
> > destH <- negotiate clientH
> > doneVar <- newEmptyMVar
> >
> > forkIO (hGetContents clientH >>= hPutStr destH >>= putMVar doneVar)
> > forkIO (hGetContents destH >>= hPutStr clientH >>= putMVar doneVar)
> > replicateM_ 2 (takeMVar doneVar)
> > mapM_ hClose [clientH, destH]
>
> This code seems like it says: [...]
After working through Gregory Collins suggestion, above, I see
that I was not reading your code correctly.
--
Jason Dusek
() ascii ribbon campaign - against html e-mail
/\ www.asciiribbon.org - against proprietary attachments
More information about the Haskell-Cafe
mailing list