Skip to Content
Python语言及其应用(第2版)
book

Python语言及其应用(第2版)

by Bill Lubanovic
March 2022
Intermediate to advanced
522 pages
13h 52m
Chinese
Posts & Telecom Press
Content preview from Python语言及其应用(第2版)
298
17
另一种常见模式是
推送
push
),或者
扇出
fanout
):将数据发送给进程池中任意可用
的工作进程。比如位于负载均衡器之后的
We
b
服务器。
与推送相反的模式是
拉取
pull
,或者
扇入
fanin
):从一个或多个资源处接收数据。
比如从多个进程处获取文本消息并将其写入单个日志文件的日志记录程序(
logger
)。
还有一种与无线电或电视广播类似的模式:
发布
订阅
publish-subscribe
pub-sub
)。
在该模式中,发布者会发送数据。对于简单的“发布
订阅”系统
,所有的订阅者都会
接收到副本。订阅者大多能够指定自己感兴趣的数据类型(通常称为
话题
),发布者只
向其发送此类数据。因此,与推送模式不同,多个订阅者可能会收到特定的数据。如果
某主题没有订阅者,则该数据将被忽略。
下面先来看几个“请求
回应”模式和“发布
订阅”模式的例子。
17.3
请求
回应
模式
这是最为人熟知的模式。你向
DNS
Web
或电子邮件服务器发出请求,服务器回应请求,
或是告知你是否存在问题。
本书已经展示过如何使用
UDP
TCP
创建一些基本请求
,但是在套接字层面构建网络应
用的难度太大。来看看
ZeroMQ
能不能帮上忙。
17.3.1 ZeroMQ
ZeroMQ
是一个库,不是服务器。
ZeroMQ
有时被描述为
增强版套接字
socket on steroid
)。
ZeroMQ
套接字实现了你希望普通套接字所具有的功能:
交换完整的消息;
重建连接;
当发送方和接收方的节奏不一致时,对数据进行缓冲。 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

可编程网络自动化

可编程网络自动化

Jason Edelman, Scott S. Lowe, Matt Oswalt
Python实用技能学习指南

Python实用技能学习指南

Posts & Telecom Press, Robert Smallshire, Austin Bingham
量子计算机编程:从入门到实践

量子计算机编程:从入门到实践

Eric R. Johnston, Nicholas Harrigan, Mercedes Gimeno-Segovia
Python编程入门与实战

Python编程入门与实战

Posts & Telecom Press, Fabrizio Romano

Publisher Resources

ISBN: 9787115586223