module Main where import Message import Control.Concurrent.Mailbox import Control.Concurrent.Mailbox.Wrapper import Network import System.IO main :: IO () main = do sock <- listenOn $ UnixSocket "test.socket" (hdl, _, _) <- accept sock inBox <- wrapReadHandle hdl (\inBox e -> inBox inBox mb Message -> mb Message -> IO () loop inBox outBox = do receiveNonBlocking inBox [ \ (MsgCommand CmdQuit) -> handler $ return () , \ m -> handler $ do putStrLn $ "Matched " ++ show m ++ " non-blocking." outBox handler $ do outBox handler $ do print m loop inBox outBox ]