Skip to content

Commit

Permalink
Update to work with the host option.
Browse files Browse the repository at this point in the history
  • Loading branch information
Cole Schlesinger committed Dec 14, 2012
1 parent 0d03879 commit 14be5b7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions examples/RemoteController.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import Frenetic.Server
import Text.JSON.Generic
import Data.Generics

main = do
main addr = do
-- putStrLn . show . encodeJSON . MsgPolicy . PolProcessIn Any $ [ActFwd AllPorts unmodified]
remoteController 6634 (-1)
remoteController addr 6634 (-1)

8 changes: 5 additions & 3 deletions src/Frenetic/Server.hs
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,17 @@ debugController host logChan pol = do
-- |Start a controller that receives and deploys JSON-formatted policies.
-- Queries and switch events are sent back in JSON format. Note that this
-- controller only supports a single connection.
remoteController :: PortNumber -- ^Port on which to listen for JSON messages.
remoteController :: Maybe String
-> PortNumber -- ^Port on which to listen for JSON messages.
-> Int -- ^Timeout (in milliseconds).
-- A negative value indicates no timeout.
-> IO ()
remoteController port timeout = withSocketsDo $ do
remoteController host port timeout = withSocketsDo $ do
-- Start the controller.
toNetCoreChan <- newChan
fromNetCoreChan <- newChan
forkIO $ forever $ nettleRemoteServer defaultNettleServerOpts toNetCoreChan
let opts = defaultNettleServerOpts { host=host }
forkIO $ forever $ nettleRemoteServer opts toNetCoreChan
-- Threads started to handle a remote connection will need to be cleaned up
-- if the connection dies.
deadChildren <- newEmptyMVar
Expand Down

0 comments on commit 14be5b7

Please sign in to comment.