/** * Execute the console command. * * @return mixed */ public function fire() { // create a log channel $log = new Logger('websocket'); $log->pushHandler(new RotatingFileHandler(storage_path() . '/logs/websocket.log', 10, Logger::DEBUG)); $config = Config::get('announcements-server'); $loop = LoopFactory::create(); $announcements = new AnnouncementsWebSocket($log); // Listen for the web server to make a message push. $broadcast = 'tcp://' . $config['broadcast']['ip'] . ':' . $config['broadcast']['port']; $this->info('Starting broadcast socket on ' . $broadcast); $context = new ZMQContext($loop); $broadcastSocket = $context->getSocket(ZMQ::SOCKET_PULL); $broadcastSocket->bind($broadcast); $broadcastSocket->on('message', array($announcements, 'onBroadcast')); // Listen for status check. $status = 'tcp://' . $config['status']['ip'] . ':' . $config['status']['port']; $this->info('Starting status socket on ' . $status); $statusSock = new SocketServer($loop); $statusSock->listen($config['status']['port'], $config['status']['ip']); new IoServer(new AnnouncementsServerStatus(), $statusSock); // Listen for WebSocket connections. $wsPort = $config['websocket']['port']; $wsIp = $config['websocket']['ip']; $this->info('Starting WebSocket socket on ws://' . $wsIp . ':' . $wsPort); $webSock = new SocketServer($loop); $webSock->listen($wsPort, $wsIp); new IoServer(new HttpServer(new WsServer($announcements)), $webSock); // Ping all clients each 2 min. $loop->addPeriodicTimer(120, function () use($announcements) { $announcements->ping(); }); $log->info('Server started'); $loop->run(); }
/** * @param InputInterface $input * @param OutputInterface $output * @return int */ protected function execute(InputInterface $input, OutputInterface $output) { $all = $input->getOption('all'); $events = $input->getOption('events'); // No filter if no options set // No filter if $all set // Filter if events set & !$all. $filter = []; if (!$all) { if ($events) { $filter = explode(",", $events); } } $loop = \React\EventLoop\Factory::create(); $context = new Context($loop); $cmdControl = $context->getSocket(\ZMQ::SOCKET_SUB); $cmdControl->connect('tcp://127.0.0.1:5566'); $cmdControl->subscribe(''); $cmdControl->on('message', function ($e) use($filter) { if (!empty($filter)) { $parsed = json_decode($e, true); if (!in_array($parsed['event'], $filter)) { return; } } echo $e . PHP_EOL; }); $loop->run(); return 0; }
/** * @param InputInterface $input * @param OutputInterface $output * @return int */ protected function execute(InputInterface $input, OutputInterface $output) { $loop = \React\EventLoop\Factory::create(); // Listen for the web server to make a ZeroMQ push after an ajax request $context = new Context($loop); $pull = $context->getSocket(\ZMQ::SOCKET_SUB); $pull->connect('tcp://127.0.0.1:5566'); // Binding to 127.0.0.1 means the only client that can connect is itself $pull->subscribe(''); $batch = 0; $pull->on('message', function ($msg) use(&$batch) { $arr = json_decode($msg); if ($arr->event == 'block') { $batch++; } }); $period = $input->getArgument('interval'); $loop->addPeriodicTimer($period, function () use(&$batch, $period) { $velocity = $batch / $period; echo " count: " . $batch . " - or " . $velocity . " per second " . PHP_EOL; $batch = 0; }); $loop->run(); return 0; }
public function __construct() { parent::__construct(function () { $consensus = new ConsensusFactory(Bitcoin::getEcAdapter()); $loop = LoopFactory::create(); $context = new ZmqContext($loop); $control = $context->getSocket(\ZMQ::SOCKET_SUB); $control->connect('tcp://127.0.0.1:5594'); $control->subscribe('control'); $control->on('messages', function ($msg) use($loop) { if ($msg[1] == 'shutdown') { $loop->stop(); } }); $results = $context->getSocket(\ZMQ::SOCKET_PUSH); $results->connect("tcp://127.0.0.1:5593"); $workers = $context->getSocket(\ZMQ::SOCKET_PULL); $workers->connect('tcp://127.0.0.1:5592'); $workers->on('message', function ($message) use($consensus, $results) { $details = json_decode($message, true); $txid = $details['txid']; $flags = $details['flags']; $vin = $details['vin']; $scriptPubKey = new Script(Buffer::hex($details['scriptPubKey'])); $tx = TransactionFactory::fromHex($details['tx']); $results->send(json_encode(['txid' => $txid, 'vin' => $vin, 'result' => $consensus->getConsensus(new Flags($flags))->verify($tx, $scriptPubKey, $vin)])); }); $loop->run(); exit(0); }); }
/** * @param InputInterface $input * @param OutputInterface $output * @return int|null|void */ protected function execute(InputInterface $input, OutputInterface $output) { //Init rena /** @var RenaApp $app */ $app = RenaApp::getInstance(); // Init react event loop $loop = Factory::create(); // Init the ZMQ push points (?) $killsWebsocket = new killsWebsocket(); $stompOut = new sendToStomp(); // Setup ZMQ for killmails being sent around $context = new Context($loop); $pull = $context->getSocket(ZMQ::SOCKET_PULL); $pull->bind("tcp://" . $app->baseConfig->getConfig("host", "zmq", "127.0.0.1") . ":" . $app->baseConfig->getConfig("port", "zmq", 5555)); $pull->on("message", array($killsWebsocket, "onMessage")); $pull->on("message", array($stompOut, "onMessage")); // Setup ratchets websocket endpoint $ratchet = new App($app->baseConfig->getConfig("host", "websocket", "localhost"), $app->baseConfig->getConfig("port", "websocket", 8800), $app->baseConfig->getConfig("ip", "websocket", "0.0.0.0"), $loop); // Add routes here, / is entry and is just spamming kills, everything else is seperate $ratchet->route("/", $killsWebsocket, array("*")); // Default route is killmails $ratchet->route("/kills", $killsWebsocket, array("*")); // Seems someone uses this too for killmails $ratchet->route("/echo", new echoWebsocket(), array("*")); // Echo route, all it'll do is echo out whatever is sent to it $ratchet->run(); }
public function testDealerRep() { $pids[] = $this->forkRepWorker(); $pids[] = $this->forkRepWorker(); $loop = new StreamSelectLoop(); $context = new Context($loop); $dealer = $context->getSocket(\ZMQ::SOCKET_DEALER); $dealer->bind('ipc://test2.ipc'); sleep(1); $msgs = array(); $dealer->on('message', function ($msg) use(&$msgs) { $msgs[] = $msg; }); $dealer->send(array('A', '', 'foo')); $dealer->send(array('B', '', 'bar')); $loop->addTimer(1, function () use($loop) { $loop->stop(); }); $loop->run(); foreach ($pids as $pid) { pcntl_waitpid($pid, $status, WUNTRACED); } $this->assertCount(2, $msgs); $this->assertContains(array('A', '', 'foobar'), $msgs); $this->assertContains(array('B', '', 'barbar'), $msgs); }
/** * @test */ public function getSocketShouldNotAddReadListenerForNonReadableSocketType() { $loop = $this->getMock('React\\EventLoop\\LoopInterface'); $loop->expects($this->never())->method('addReadStream'); $context = new Context($loop); $context->getSocket(ZMQ::SOCKET_PUSH); }
protected function bindZMQPush() { // Listen for the web server to make a ZeroMQ push after an event firing $context = new Context($this->loop); $pull = $context->getSocket(ZMQ::SOCKET_PULL); // Binding to 127.0.0.1 means the only client that can connect is itself $pull->bind('tcp://127.0.0.1:9091'); $pull->on('message', array($this->pusher, 'onNewItem')); }
public function __construct() { parent::__construct(function () { $loop = LoopFactory::create(); $context = new ZmqContext($loop); $socket = $context->getSocket(\ZMQ::SOCKET_REP); $socket->bind("tcp://127.0.0.1:5591"); $workers = $context->getSocket(\ZMQ::SOCKET_PUSH); $workers->bind('tcp://127.0.0.1:5592'); $sub = $context->getSocket(\ZMQ::SOCKET_SUB); $sub->connect('tcp://127.0.0.1:5594'); $sub->subscribe('control'); $sub->on('messages', function ($msg) use($loop) { if ($msg[1] == 'shutdown') { $loop->stop(); } }); /** * @var \React\Promise\Deferred[] */ $deferredSet = []; $results = []; $socket->on('message', function ($message) use($socket, $workers, &$results, &$deferredSet) { // Incoming work. Distribute. $payload = json_decode($message, true); $batch = []; $work = ["txid" => $payload['txid'], "tx" => $payload['tx'], "flags" => $payload['flags'], "vin" => null, "scriptPubKey" => null]; // Send to workers, and create a Promise for each result. foreach ($payload['scripts'] as $vin => $scriptPubKey) { $work['vin'] = $vin; $work['scriptPubKey'] = $scriptPubKey; $deferred = new \React\Promise\Deferred(); $deferredSet[$payload['txid'] . $vin] = $deferred; $batch[] = $deferred->promise(); $workers->send(json_encode($work)); } // Once all promises have resolved, return outcome to socket. \React\Promise\all($batch)->then(function ($results) use($socket) { $final = true; foreach ($results as $result) { $final &= $result['result']; } $socket->send($final); }); }); $results = $context->getSocket(\ZMQ::SOCKET_PULL); $results->bind("tcp://127.0.0.1:5593"); $results->on('message', function ($message) use(&$deferredSet) { $payload = json_decode($message, true); $deferredSet[$payload['txid'] . $payload['vin']]->resolve($payload); }); $loop->run(); exit(0); }); }
public function __construct($options, LoopInterface $loop, LoggerInterface $logger) { $this->logger = $logger; $context = new Context($loop); $this->pull = $context->getSocket(\ZMQ::SOCKET_SUB); $this->pull->setSockOpt(\ZMQ::SOCKOPT_SUBSCRIBE, ""); $this->pull->connect(sprintf('%s://%s:%s', $options['protocol'], $options['host'], $options['port'])); $this->pull->on('error', function ($e) use($logger) { $logger->error('TaskManager Subscriber received an error.', ['exception' => $e]); }); }
/** * ZmqDebug constructor. * @param NodeInterface $node * @param Context $context */ public function __construct(NodeInterface $node, Context $context) { $this->socket = $context->getSocket(\ZMQ::SOCKET_PUB); $this->socket->bind('tcp://127.0.0.1:5566'); $node->on('event', function ($event, array $params) { $this->log($event, $params); }); $node->headers()->on('tip', [$this, 'logTip']); $node->blocks()->on('block', [$this, 'logBlock']); $node->chains()->on('retarget', [$this, 'logRetarget']); }
/** * Connect to ZMQ socket and listen to incoming message * * @param $loop */ protected function setupZmqPuller($loop) { $host = Config::get('socket.zmqHost', 'localhost'); $port = Config::get('socket.zmqPort', '5555'); $persistentId = Config::get('socket.socketPullId', 'paxifi.zmq.pull'); $context = new Context($loop); $pull = $context->getSocket(\ZMQ::SOCKET_PULL, $persistentId); $pull->bind("tcp://{$host}:{$port}"); $pull->on('message', [$this->socketServer, 'onMessage']); $this->info(sprintf('Server listening to incoming messages from ZMQ at %s:%s', $host, $port)); }
protected function execute(InputInterface $input, OutputInterface $output) { $loop = Factory::create(); $pusher = $this->getContainer()->get('gameList'); $context = new Context($loop); $pull = $context->getSocket(\ZMQ::SOCKET_PULL); $pull->bind('tcp://127.0.0.1:5555'); $pull->on('message', [$pusher, 'onBlogEntry']); $webSock = new Server($loop); $webSock->listen(8081, '0.0.0.0'); $webServer = new IoServer(new HttpServer(new WsServer(new WampServer($pusher))), $webSock); $loop->run(); }
/** * Start the websocket server */ public function start() { $this->__loop = Factory::create(); $pusher = new CakeWampAppServer(); $context = new Context($this->__loop); $pull = $context->getSocket(ZMQ::SOCKET_PULL); $pull->bind("tcp://" . Configure::read('CakeRatchet.ZMQServer.host') . ":" . Configure::read('CakeRatchet.ZMQServer.port')); $pull->on('message', array($pusher, 'onBlogEntry')); $webSock = new Server($this->__loop); $webSock->listen(Configure::read('CakeRatchet.Server.port'), Configure::read('CakeRatchet.Server.host')); $this->__ioServer = new IoServer(new HttpServer(new WsServer(new WampServer($pusher))), $webSock); $this->__loop->run(); }
/** * main() method. * * @return bool|int Success or error code. */ public function main() { $loop = Factory::create(); $pusher = new SocketPusher(); $context = new Context($loop); $pull = $context->getSocket(ZMQ::SOCKET_PULL); $pull->bind(Configure::read('CakeWebsocket.ZMQ.Shell.host')); $pull->on('message', array($pusher, 'onMessage')); $webSock = new Server($loop); $webSock->listen(Configure::read('CakeWebsocket.Socket.port'), Configure::read('CakeWebsocket.Socket.host')); $webServer = new IoServer(new HttpServer(new WsServer(new WampServer($pusher))), $webSock); $loop->run(); }
public function execute(AgaviRequestDataHolder $request_data) { $event_loop = EventLoopFactory::create(); $event_pusher = new EventPusher(); $context = new Context($event_loop); $pull_socket = $context->getSocket(ZMQ::SOCKET_PULL); $pull_socket->bind(sprintf('tcp://%s:%s', AgaviConfig::get('event_pub.pull_socket.host'), AgaviConfig::get('event_pub.pull_socket.port'))); // sent by command handlers via zmq $pull_socket->on('message', array($event_pusher, 'onNewEvent')); $web_socket = new Server($event_loop); $web_socket->listen(AgaviConfig::get('event_pub.web_socket.port'), AgaviConfig::get('event_pub.web_socket.host')); $web_server = new IoServer(new HttpServer(new WsServer($event_pusher)), $web_socket); $event_loop->run(); return AgaviView::NONE; }
protected function execute(InputInterface $input, OutputInterface $output) { $game = $this->getContainer()->get("game"); $loop = Factory::create(); $context = new Context($loop); $push = $context->getSocket(\ZMQ::SOCKET_PUSH); $push->connect('tcp://127.0.0.1:5555'); $webSock = new Reactor($loop); $webSock->listen(8082, '0.0.0.0'); $webServer = new IoServer(new HttpServer(new WsServer(new WampServer($game))), $webSock); $flashSock = new Reactor($loop); $flashSock->listen(8430, '0.0.0.0'); $logSock = new Reactor($loop); $logSock->listen(9000, '0.0.0.0'); $loop->run(); }
/** * Run the Larapush Server * * @param $port number * @return void */ public function run($port) { $loop = ReactLoop::create(); // ZMQ Context pulling ZeroMQ connections from the SERVER $context = new ZMQContext($loop); // Waiting for ZeroMQ messages from server-side $pull = $context->getSocket(\ZMQ::SOCKET_PULL, \Config::get('larapush::pers_socket_name')); $pull->bind(\Config::get('larapush::zmqConnect') . ':' . \Config::get('larapush::zmqPort')); // On message, execute pushMessageToServer($message) in LarapushBroadcaster $pull->on('message', [$this->broadcaster, 'pushMessageToServer']); // WebSocket server for CLIENTS waiting for real-time updates $webSocket = new SocketServer($loop); $webSocket->listen($port, \Config::get('larapush::socketConnect')); $webServer = new IoServer(new HttpServer(new WsServer(new WampServer(new LarapushEventListener($this->broadcaster, $this->storage)))), $webSocket); $loop->run(); }
/** * Inicia notificaciones real time y observador contexto */ public function actionIniciar() { $loop = Factory::create(); $pusher = new Pusher(); // Listen for the web server to make a ZeroMQ push after an ajax request $context = new \React\ZMQ\Context($loop); $pull = $context->getSocket(\ZMQ::SOCKET_PULL); $pull->bind('tcp://127.0.0.1:5555'); // Binding to 127.0.0.1 means the only client that can connect is itself $pull->on('message', array($pusher, 'enEmision')); // Set up our WebSocket server for clients wanting real-time updates $webSock = new \React\Socket\Server($loop); $webSock->listen(8081, '0.0.0.0'); // Binding to 0.0.0.0 means remotes can connect $webServer = new \Ratchet\Server\IoServer(new \Ratchet\Http\HttpServer(new \Ratchet\WebSocket\WsServer(new \Ratchet\Wamp\WampServer($pusher))), $webSock); $loop->run(); }
/** * Execute the console command. * * @return mixed */ public function handle() { $loop = Factory::create(); $PushNotificationManager = new PushNotificationManager(); // Listen for the web server to make a ZeroMQ push after an ajax request $context = new Context($loop); $pull = $context->getSocket(\ZMQ::SOCKET_PULL); $pull->bind('tcp://127.0.0.1:5555'); // Binding to 127.0.0.1 means the only client that can connect is itself $pull->on('message', array($PushNotificationManager, 'onMessage')); // Set up our WebSocket server for clients wanting real-time updates $webSock = new Server($loop); $webSock->listen(8080, '0.0.0.0'); // Binding to 0.0.0.0 means remotes can connect $webServer = new IoServer(new HttpServer(new WsServer(new WampServer($PushNotificationManager))), $webSock); $loop->run(); }
/** * Execute the console command. * * @return mixed */ public function handle() { $loop = ReactLoop::create(); $pusher = new Pusher(); // Listen for the web server to make a ZeroMQ push after an ajax request $context = new ReactContext($loop); $pull = $context->getSocket(\ZMQ::SOCKET_PULL); $pull->bind('tcp://127.0.0.1:5555'); // Binding to 127.0.0.1 means the only client that can connect is itself $pull->on('message', [$pusher, 'broadcastData']); // Set up our WebSocket server for clients wanting real-time updates $webSock = new ReactServer($loop); $webSock->listen(8080, '0.0.0.0'); // Binding to 0.0.0.0 means remotes can connect $webServer = new IoServer(new HttpServer(new WsServer(new WampServer($pusher))), $webSock); $this->info('Run Pusher Server...'); $loop->run(); }
/** * @param Context $context * @param BitcoinNode $node * @param ScriptThreadControl $threadControl */ public function __construct(Context $context, BitcoinNode $node, ScriptThreadControl $threadControl) { $cmdControl = $context->getSocket(\ZMQ::SOCKET_REP); $cmdControl->bind('tcp://127.0.0.1:5560'); $cmdControl->on('message', function ($e) use($threadControl, $node) { $result = ['error' => 'Unrecognized command']; if ($e === 'shutdown') { $threadControl->shutdown(); $result = $this->onShutdown($threadControl); } elseif ($e === 'info') { $result = $this->onInfo($node); } $this->socket->send(json_encode($result, JSON_PRETTY_PRINT)); if ($e === 'shutdown') { $node->stop(); } }); $this->socket = $cmdControl; }
/** * @param InputInterface $input * @param OutputInterface $output * @return int */ protected function execute(InputInterface $input, OutputInterface $output) { $loop = \React\EventLoop\Factory::create(); $pusher = new DebugPusher(); // Listen for the web server to make a ZeroMQ push after an ajax request $context = new Context($loop); $pull = $context->getSocket(\ZMQ::SOCKET_SUB); $pull->connect('tcp://127.0.0.1:5566'); // Binding to 127.0.0.1 means the only client that can connect is itself $pull->subscribe(''); $pull->on('message', array($pusher, 'onMessage')); // Set up our WebSocket server for clients wanting real-time updates $webSock = new \React\Socket\Server($loop); $webSock->listen(8080, '0.0.0.0'); // Binding to 0.0.0.0 means remotes can connect new IoServer(new HttpServer(new WsServer(new WampServer($pusher))), $webSock); $loop->run(); return 0; }
/** * Execute the console command. * * @return mixed */ public function fire() { $port = (int) $this->option("port"); if (!$port) { $port = 7778; } $loop = Factory::create(); $pusher = new Pusher(); $context = new Context($loop); $pull = $context->getSocket(ZMQ::SOCKET_PULL); $pull->bind('tcp://127.0.0.1:5555'); $pull->on('message', array($pusher, 'onBlogEntry')); $webSock = new Server($loop); $webSock->listen($port, '0.0.0.0'); $webServer = new IoServer(new HttpServer(new WsServer(new WampServer($pusher))), $webSock); $this->info('wamp boot'); $this->info('Listening on port ' . $port); $loop->run(); }
/** * Handle incoming console command * * @return void */ public function handle() { $this->info('Push notification started'); $loop = ReactFactory::create(); $pusher = new Pusher($this->app, $this->topicHandlers); $webServerBinding = config('inoplate.velatchet.zmq.server_binding'); $webSocketHost = config('inoplate.velatchet.zmq.host'); $webSocketPort = config('inoplate.velatchet.zmq.port'); // Listen for the web server to make a ZeroMQ push after an ajax request $context = new Context($loop); $pull = $context->getSocket(ZMQ::SOCKET_PULL); $pull->bind($webServerBinding); $pull->on('message', array($pusher, 'onMessagePushed')); // Set up our WebSocket server for clients wanting real-time updates $webSock = new Server($loop); $webSock->listen($webSocketPort, $webSocketHost); // Binding to 0.0.0.0 means remotes can connect $webServer = new IoServer(new HttpServer(new WsServer(new WampServer($pusher))), $webSock); $loop->run(); }
/** * @param Context $context * @param NodeInterface $node * @param CommandInterface[] $commands */ public function __construct(Context $context, NodeInterface $node, array $commands = []) { foreach ($commands as $command) { $this->commands[$command->getName()] = $command; } $cmdControl = $context->getSocket(\ZMQ::SOCKET_REP); $cmdControl->bind('tcp://127.0.0.1:5560'); $cmdControl->on('message', function ($e) use($node) { $input = json_decode($e, true); if (json_last_error() !== JSON_ERROR_NONE || !isset($input['cmd'])) { return $this->respondError('Malformed request'); } if (!isset($this->commands[$input['cmd']])) { return $this->respondError('Unknown command'); } $params = isset($input['params']) && is_array($input['params']) ? $input['params'] : []; $result = $this->commands[$input['cmd']]->run($node, $params); return $this->respond($result); }); $this->socket = $cmdControl; }
/** * @param array[string]string $connUris */ private function initSockets(array $connUris) { // Create context $this->reactLoop = ReactFactory::create(); /** @var ReactZmqContext|\ZMQContext $reactZmqContext */ $reactZmqContext = new ReactZmqContext($this->reactLoop); $this->hbSocket = $reactZmqContext->getSocket(\ZMQ::SOCKET_REP); $this->hbSocket->bind($connUris['hb']); $this->iopubSocket = $reactZmqContext->getSocket(\ZMQ::SOCKET_PUB); $this->iopubSocket->bind($connUris['iopub']); $this->controlSocket = $reactZmqContext->getSocket(\ZMQ::SOCKET_ROUTER); $this->controlSocket->bind($connUris['control']); $this->stdinSocket = $reactZmqContext->getSocket(\ZMQ::SOCKET_ROUTER); $this->stdinSocket->bind($connUris['stdin']); $this->shellSocket = $reactZmqContext->getSocket(\ZMQ::SOCKET_ROUTER); $this->shellSocket->bind($connUris['shell']); }
/** * Get socket wrapper. * * @param Context $context * @return React\ZMQ\SocketWrapper */ protected function pullSocket(Context $context) { $pull = $context->getSocket(ZMQ::SOCKET_PULL); $pull->bind("tcp://" . static::HOST_IP . ":" . static::HOST_PORT); $pull->on('message', array($this->pusher, $this->eventName)); return $pull; }
/** * Enable the option to push messages from * the Server to the client * * @return void */ protected function enablePush() { if (!class_exists('\\React\\ZMQ\\Context')) { $this->error('React/ZMQ dependency is required to enable push. Stopping server.', 1); die; } $context = new ZMQContext($this->loop); $this->pull = $context->getSocket(ZMQ::SOCKET_PULL, self::SOCKET_PULL_ID . '.' . App::environment()); $this->pull->bind('tcp://127.0.0.1:' . $this->option('push-port')); $this->pull->on('message', [$this->Dispatcher, 'push']); $this->info('Push enabled on port <comment>[' . $this->option('push-port') . ']</comment>', 1); }
#!/usr/bin/env php <?php require __DIR__ . '/../vendor/autoload.php'; use React\ZMQ\Context; //use React\EventLoop\Factory; use Ratchet\Server\IoServer; use Ratchet\Http\HttpServer; use Ratchet\WebSocket\WsServer; use App\System\ClockServer; use App\System\Daemon; $daemon = new Daemon(__DIR__ . '/../pids/clock' . '.pid'); $daemon->smallInit(); $transport = 'tcp'; $address = '127.0.0.1'; $port = '5881'; //$loop = Factory::create(); ??? $clock = new ClockServer(); $server = IoServer::factory(new HttpServer(new WsServer($clock)), 8080); $context = new Context($server->loop); $pull = $context->getSocket(ZMQ::SOCKET_PULL); $pull->bind($transport . "://" . $address . ":" . $port); // Binding to 127.0.0.1 means the only client that can connect is itself $pull->on('message', array($clock, 'onClockMessage')); $server->run();