linux下安装zeromq及其测试
2014-06-15 17:48
477 查看
linux下安装zeromq及其测试
wget http://download.zeromq.org/zeromq-2.1.7.tar.gz
2、安装相关软件
$ sudo apt-get install libtool autoconf automake
$ sudo apt-get install uuid-dev g++
$ sudo apt-get install python-dev
3、编译安装zmq
$ ./configure
$ make
$ sudo make install
$ sudo ldconfig
4、pyzmq
在http://www.zeromq.org/bindings:python下载。
$ python setup.py build_ext --inplace
$ python setup.py test
$ sudo python setup.py install
5、测试
$ python -c "import zmq"
通过就可以了。
client_mq.py的代码:
server_mq.py的代码:
测试结果如下:
参考资料:
1. http://zguide.zeromq.org/page:all
2. http://www.firefoxbug.com/?p=2755
1. 在ubuntu上安装zeromq以及python组件
1、在http://www.zeromq.org/area:download页面下载最新的zeromq 2.1.7.wget http://download.zeromq.org/zeromq-2.1.7.tar.gz
2、安装相关软件
$ sudo apt-get install libtool autoconf automake
$ sudo apt-get install uuid-dev g++
$ sudo apt-get install python-dev
3、编译安装zmq
$ ./configure
$ make
$ sudo make install
$ sudo ldconfig
4、pyzmq
在http://www.zeromq.org/bindings:python下载。
$ python setup.py build_ext --inplace
$ python setup.py test
$ sudo python setup.py install
5、测试
$ python -c "import zmq"
通过就可以了。
2. 测试
下面写一个客户端和服务器端通信的例子。client_mq.py的代码:
import zmq context = zmq.Context() # Socket to talk to server print "COnnecting to hello world server..." socket = context.socket(zmq.REQ) socket.connect("tcp://localhost:5555") # Do 10 requests, waiting each time for a response for request in range (1,10): print "Sending request", request, "..." socket.send("Hello") #Get the reply message = socket.recv() print "Receives reply" , request, "[", message, "]"
server_mq.py的代码:
import zmq import time context = zmq.Context() socket = context.socket(zmq.REP) socket.bind("tcp://*:5555") count = 0 while True: # Wait for next request from client message = socket.recv() count += 1 print "Receive request: ",message,count #do some 'work' time.sleep(1) socket.send("World")
测试结果如下:
chenglin@chenglin-ubuntu1:~/zeromq$ python client_zmq.py COnnecting to hello world server... Sending request 1 ... Receives reply 1 [ World ] Sending request 2 ... Receives reply 2 [ World ] Sending request 3 ... Receives reply 3 [ World ] Sending request 4 ... Receives reply 4 [ World ] Sending request 5 ... Receives reply 5 [ World ] Sending request 6 ... Receives reply 6 [ World ] Sending request 7 ... Receives reply 7 [ World ] Sending request 8 ... Receives reply 8 [ World ] Sending request 9 ... Receives reply 9 [ World ]
chenglin@chenglin-ubuntu1:~/zeromq$ python server_zmq.py Receive request: Hello 1 Receive request: Hello 2 Receive request: Hello 3 Receive request: Hello 4 Receive request: Hello 5 Receive request: Hello 6 Receive request: Hello 7 Receive request: Hello 8 Receive request: Hello 9
参考资料:
1. http://zguide.zeromq.org/page:all
2. http://www.firefoxbug.com/?p=2755
相关文章推荐
- opencv在Linux下的安装及其测试
- Linux系统下JDK的安装及其配置方法介绍
- sipp 在windows/linux下的安装和使用及性能测试
- linux下的vivi、内核、root的安装步骤与测试
- 转:linux线程池及其测试
- 安装&测试qt-sdk-linux-x86-opensource-2009.01.bin
- Linux下Apache2.0简单安装、配置、测试过程
- Linux下vsftp安装的测试
- 【转】Google Protocol Buffers之Visual Studio 2005安装配置及其测试步骤[基于C++]
- linux 下 OV511 摄像头的安装与测试
- 在vmware软件环境下安装windows,linux及其工具
- 编译和安装linux内核2.6.x,一个简单的内核驱动测试
- redhat linux as 5 安装oracle 10g的详细过程(已经做过测试) - radkitty的专栏 - CSDNBlog
- windows下的vmware安装linux上网问题-已测试通过
- redhat linux as 5 安装oracle 10g的详细过程(已经做过测试)
- Google Protocol Buffers之Visual Studio 2005安装配置及其测试步骤[基于C++]
- Domino V8 在 UNIX/Linux 平台上的安装及其常见问题---转载
- Linux压力测试工具webbench的安装使用介绍
- LINUX下安装jdk过程及其环境变量配置
- bdb及其在php下扩展的安装 & bdb性能测试