> module Main where > import IO > import Distributed > data Msg = Ping Pid | Connect Pid | Pong | Quit Pid deriving (Read,Show) > instance Serialize Msg > main = do > hSetBuffering stdout NoBuffering > Distributed.start (do > me <- self > valStr <- proc $ myGetVarDefault "CNT" "1000" > let val = ((read valStr) :: Int) > host <- proc $ myGetVarDefault "HOST" "localhost" > remoteSend (Hostname host) (Nodename "LELoop") "Reader" (Connect me) > receive (\v -> case v of > Connect pid -> do > loop me pid val > pid Quit me > receive (\v -> case v of > Quit _ -> return () > ) > ) > halt > ) "" > putStrLn "" > loop :: Pid -> Pid -> Int -> DIO Msg () > loop _ _ 0 = return () > loop me pid (i+1) = do > pid Ping me > proc $ putStr "." > receive (\v -> case v of > Pong -> return () > ) > loop me pid i