zeromy quick start - python
软件:
pip install pyzmq
代码:
==server.py
#
# Hello World server in Python
# Binds REP socket to tcp://*:5555
# Expects "Hello" from client, replies with "World"
#
import zmq
import time
context = zmq.Context()
socket = context.socket(zmq.REP)
socket.bind("tcp://*:5555")
while True:
# Wait for next request from client
message = socket.recv()
print ("Received request: ", message)
# Do some 'work'
time.sleep (1) # Do some 'work'
# Send reply back to client
socket.send_string("World")
==client.py
#
# Hello World client in Python
# Connects REQ socket to tcp://localhost:5555
# Sends "Hello" to server, expects "World" back
#
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_string ("Hello")
# Get the reply.
message = socket.recv()
print ("Received reply ", request, "[", message, "]" )
步骤
打开一个命令行,执行python server.py
打开一个命令行,执行python client.py
参考:
https://blog.csdn.net/kent45/article/details/10397917
zeromy quick start - python的更多相关文章
- Quick Reference Card Urls For Web Developer
C# C# Cheatsheet & Notes Coding Guidelines for C# 3.0, 4.0, 5.0 Core C# and .NET Quick Reference ...
- A look at WeChat security
原文地址:http://blog.emaze.net/2013/09/a-look-at-wechat-security.html TL;DR: Any (unprivileged) applicat ...
- Red Hat Enterprise Linux 8正式发布
现在CENTOS 8还没有发布. 了解其主要特点. https://developers.redhat.com/blog/2019/05/07/red-hat-enterprise-linux-8-n ...
- (转) Quick Guide to Build a Recommendation Engine in Python
本文转自:http://www.analyticsvidhya.com/blog/2016/06/quick-guide-build-recommendation-engine-python/ Int ...
- [文摘]Quick Start to Client side COM and Python
摘自:PyWin32.chm Introduction This documents how to quickly start using COM from Python. It is not a t ...
- What does Quick Sort look like in Python?
Let's talk about something funny at first. Have you ever implemented the Quick Sort algorithm all by ...
- Python Quick list dir
昨天 Python释放了 3.5 ,添加了 os.scandir 根据文档该API比os.listdir快Docs which speeds it up by 3-5 times on POSIX s ...
- Python Quick Start
1.安装Python 官网下载python: https://www.python.org/ 有2.x 3.x版本, 注意,python3.0不向下兼容2.x版本,有很多包3.0不提供 下载完后直接点 ...
- 快速排序算法回顾 --冒泡排序Bubble Sort和快速排序Quick Sort(Python实现)
冒泡排序的过程是首先将第一个记录的关键字和第二个记录的关键字进行比较,若为逆序,则将两个记录交换,然后比较第二个记录和第三个记录的关键字.以此类推,直至第n-1个记录和第n个记录的关键字进行过比较为止 ...
随机推荐
- POJ - 1942 D - Paths on a Grid
Imagine you are attending your math lesson at school. Once again, you are bored because your teacher ...
- innodb mvcc,事务隔离级别,读写锁
mvcc其实和copyonwritelist的思路差不多:读不加锁,写加锁,事务提交之后释放锁,并且延伸的是,在UNdolog里面保存了几个版本,实现不同的隔离级别.如果读数据页里面最新的数据,那么就 ...
- 很Low的三级菜单程序
# -*-coding:utf-8-*- # Author:sunhao province={ '广东省':{ '深圳市':['南山区','龙岗区','福田区'], '广州市':['荔湾区','海珠区 ...
- C#窗体的浮动及隐藏
using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using Sy ...
- mod_fcgid: HTTP request length 136136 (so far) exceeds MaxRequestLen (131072)
原来是fastcgi模式下的设置问题,需要在配置文件.htaccess或者直接在apache的配置文件http.conf 中指明,如下: 查看官方说明有这么一句:Default: FcgidMaxRe ...
- winform 点击控件拖动窗体
private Point mPoint = new Point(); private void 选择控件_MouseDown(object sender, MouseEventArgs e) { m ...
- winform 使用线程
我这里写一个线程里创建一个窗体调用父窗体的方法 private void button4_Click(object sender, EventArgs e) { button4.Text = &quo ...
- 路由器DHCP服务及DHCP中继
实验要求:掌握路由配置DHCP服务配置 拓扑如下: R1enable 进入特权模式config terminal 进入全局模式interface s0/0/0 进入端口ip address 192 ...
- CodeForces - 441E:Valera and Number (DP&数学期望&二进制)
Valera is a coder. Recently he wrote a funny program. The pseudo code for this program is given belo ...
- js 关于本地文件的处理
https://developer.mozilla.org/zh-CN/docs/Web/API/File/Using_files_from_web_applications