zeromq php,在Apache内部的PHP脚本中使用ZeroMQ
我想使用ZeroMQ發(fā)布者/訂閱者將我的Web應(yīng)用程序中的數(shù)據(jù)分發(fā)到多個(gè)服務(wù)器.
我使用Apache和PHP作為Web應(yīng)用程序,我的PHP腳本的工作原理如下:
//Initialization
$context = new ZMQContext();
$publisher = $context->getSocket(ZMQ::SOCKET_PUB);
$publisher->bind("tcp://*:5556");
//Then publishing for testing:
$publisher->send("test");
$publisher->send("test");
$publisher->send("test");
$publisher->send("test");
$publisher->send("test");
為了測(cè)試,我從python的文檔中修改了一個(gè)訂閱者:
import sys
import zmq
# Socket to talk to server
context = zmq.Context()
socket = context.socket(zmq.SUB)
socket.connect ("tcp://localhost:5556")
# Subscribe to zipcode, default is NYC, 10001
socket.setsockopt(zmq.SUBSCRIBE, "")
print "Waiting..."
# Process 5 updates
for update_nbr in range (5):
string = socket.recv()
print string
當(dāng)我從命令行運(yùn)行php腳本但不通過(guò)Apache工作時(shí)(當(dāng)腳本通過(guò)Web瀏覽器運(yùn)行時(shí)),整個(gè)過(guò)程都有效.
我應(yīng)該對(duì)Apache配置做些什么來(lái)使其工作?
謝謝
亞歷山大
總結(jié)
以上是生活随笔為你收集整理的zeromq php,在Apache内部的PHP脚本中使用ZeroMQ的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: php 的cookie设置时间,php
- 下一篇: php 文件保存函数,PHP文件函数