[Haskell-cafe] network-conduit proxy

grant thelff at hotmail.com
Fri Mar 9 18:44:29 CET 2012


I am trying to get a proxy working using the network-conduit package on windows.
So I send a request to port 5002 and that gets forwarded to another port 5000 
where I have a simple echo server running.

I made a stab at it, but get intermittent send errors after the first connection

Here is the code:
{-# OPTIONS -Wall #-}
import Data.Conduit
import Data.Conduit.Network
import Network (withSocketsDo)
import Control.Monad.IO.Class (liftIO)
import Control.Monad.Trans.Resource

main::IO ()
main = 
  withSocketsDo $ runTCPClient (ClientSettings 5000 "localhost") $ 
    \src1 sink1 -> do
    liftIO $ print "in tcpclient section"
    liftIO $ withSocketsDo $ runTCPServer (ServerSettings 5002 Nothing) $ 
      \src sink -> do
      liftIO $ print "in tcpserver section"
      _ <- liftIO $ runResourceT $ resourceForkIO $ do
          src1 $$ sink 
          return ()
      src $$ sink1 
        
      
Thanks for any help,
Grant
      
        





More information about the Haskell-Cafe mailing list