----------------------------------------------------------------------------- -- -- Module : Control.Concurrent.Network.Slave -- Copyright : (C) 2010, Paul Sonkoly -- License : BSD style -- -- Maintainer : Paul Sonkoly -- Stability : provisional -- Portability : -- -- | Slave processes have a single connection towards the master for simplicity. -- Communication is done by using 'NVar' variables similar to 'MVar' in Concurrent. -- ----------------------------------------------------------------------------- module Control.Concurrent.Network.Slave ( -- * Constructors NCContext(..) -- * Functions , initSlave ) where import System.Log.Logger import System.IO import Network -- | the NC Context data NCContext = NCC { hdl :: Handle } -- | Initialises a slave process returning the NC context. initSlave :: IO NCContext initSlave = do debugM rootLoggerName "Initialise slave" infoM rootLoggerName "connecting to localhost 9999" hdl <- connectTo "localhost" $ PortNumber 9999 hSetBuffering hdl NoBuffering return NCC { hdl = hdl }