Skip to content

@qnikst /gist:2008113
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
tcp proxy
{-# OPTIONS -Wall #-}
import Data.Conduit
import Data.Conduit.Network
import Control.Monad.IO.Class (liftIO)
import Control.Monad.Trans.Resource
import Control.Concurrent.Lifted (fork)
import Control.Concurrent (killThread)
main::IO ()
main =
runTCPServer (ServerSettings 5002 Nothing) $ \clientSrc clientSink -> do
withFork_ (liftIO $ fork $ runResourceT $ serverSrc $$ clientSink) $ do
liftIO $ runTCPClient (ClientSettings 5000 "localhost") $ \serverSrc serverSink ->
clientSrc $$ serverSink
withFork act = EL.bracket (CL.fork act) CL.killThread
withFork_ act = withFork act . const
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.