git.iko.soy/distributed-process
on master help sign in
Modify example for TCP.
commitfdcb722998e3ae523d67088abf8dee511f19da97 authorNicolas Wu <nick@well-typed.com> dateWed 14 Dec 2011, 10:45 (15 years ago) parent5d58e20
1 file changed+7−6
examples/DemoProcess.hs+7−6
examples/DemoProcess.hs+7−6
@@ -3,18 +3,19 @@ module DemoProcess where
33import Control.Distributed.Process
44import Control.Concurrent (threadDelay)
55
6−import Network.Transport.MVar (mkTransport)
6+import Network.Transport.TCP (mkTransport, TCPConfig (..))
7+
8+import Debug.Trace
79
810demo1 = do
9− trans <- mkTransport
11+ trans <- mkTransport $ TCPConfig undefined "127.0.0.1" "8080"
1012 node <- newLocalNode trans
11− print "foo"
13+ print "Starting node"
1214 runProcess node $ do
13− liftIO $ print "bar"
15+ liftIO $ print "Starting process"
1416 lpid1 <- spawnLocal (logger 1)
1517-- liftIO $ print "baz"
1618-- lpid2 <- spawnLocal (logger 2)
17−
1819 spawnLocal (chatty "jim1" lpid1)
1920-- spawnLocal (chatty "jim2" lpid2)
2021 spawnLocal (chatty "bob1" lpid1)
@@ -31,5 +32,5 @@ chatty name target = do
3132logger :: Int -> Process ()
3233logger n = do
3334 str <- expect
34− liftIO $ putStrLn $ show n ++ ": " ++ str
35+ liftIO . putStrLn $ show n ++ ": " ++ str
3536 logger (n+1)