Skip to Content
构建可扩展分布式系统:方法与实践
book

构建可扩展分布式系统:方法与实践

by Ian Gorton
May 2024
Intermediate
278 pages
5h 24m
Chinese
China Machine Press
Content preview from 构建可扩展分布式系统:方法与实践
分布式系统要点
|
43
3.2
远程方法调用
使用直接与传输层协议
TCP
UDP
交互的底层
API
来编写分布式应用程序是完全可行
的。最常见的方法是调用标准化套接字库
请参阅边栏中的概述。这是你永远不希望
做的事情,因为套接字很复杂而且容易出错。本质上,套接字在两个节点之间创建了
一个双向管道,你可以使用它来发送数据流。幸运的是,有更好的方法来构建分布式通
信,我将在本节中描述,这些方法抽象掉了使用套接字的大部分复杂性。然而,套接字
仍然是底层实现,了解一些知识是必要的。
套接字概述
套接字是客户端和服务器之间双向网络连接的一个端点。套接字由节点 IP 地址和端
口的组合来标识。端口是唯一的数字标识符,它允许节点支持在该节点上运行的多
个应用程序的通信。
每个 IP 地址都可以支持 65 535 TCP 端口和另外 65 535 UDP 端口。在服务器
上,每个
{<IP Address>, <port>}
的组合都可以与一个应用程序相关联。这种组合
形成了一个独特的端点,传输层使用该端点将数据传送到所需的服务器。
套接字连接由客户端和服务器 IP 地址与端口的唯一组合标识,即“ < 客户端 IP
址、客户端端口、服务器 IP 地址、服务器端口 >。每个唯一连接还在客户端和服
务器上分配一个套接字描述符。创建连接后,客户端以流的形式向服务器发送数据,
服务器以结果作为响应。套接字库支持两种协议,选项 SOCK_STREAM TCP 的,选
SOCK_DGRAM UDP 的。
你可以直接向套接字 ...
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

What Successful Brick-and-Mortar Retailers Get Right

What Successful Brick-and-Mortar Retailers Get Right

Rob Angell
What Successful Project Managers Do

What Successful Project Managers Do

W. Scott Cameron, Jeffrey S. Russell, Edward J. Hoffman, Alexander Laufer
Three Essentials for Agentic AI Security

Three Essentials for Agentic AI Security

Paolo Dal Cin, Daniel Kendzior, Yusof Seedat, Renato Marinho

Publisher Resources

ISBN: 9787111750697