惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
Secure Thoughts
Security Latest
Security Latest
Simon Willison's Weblog
Simon Willison's Weblog
O
OpenAI News
GbyAI
GbyAI
L
LINUX DO - 最新话题
A
Arctic Wolf
T
Tor Project blog
G
GRAHAM CLULEY
I
InfoQ
博客园_首页
IT之家
IT之家
The Register - Security
The Register - Security
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
P
Proofpoint News Feed
The GitHub Blog
The GitHub Blog
Blog — PlanetScale
Blog — PlanetScale
N
Netflix TechBlog - Medium
K
Kaspersky official blog
博客园 - 三生石上(FineUI控件)
S
SegmentFault 最新的问题
U
Unit 42
PCI Perspectives
PCI Perspectives
量子位
P
Palo Alto Networks Blog
S
Securelist
T
Troy Hunt's Blog
博客园 - 【当耐特】
Recorded Future
Recorded Future
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
S
Security Affairs
Engineering at Meta
Engineering at Meta
T
The Blog of Author Tim Ferriss
博客园 - 聂微东
罗磊的独立博客
N
News and Events Feed by Topic
人人都是产品经理
人人都是产品经理
B
Blog RSS Feed
NISL@THU
NISL@THU
C
Cisco Blogs
T
Threatpost
有赞技术团队
有赞技术团队
Forbes - Security
Forbes - Security
Hugging Face - Blog
Hugging Face - Blog
Last Week in AI
Last Week in AI
T
The Exploit Database - CXSecurity.com
Cloudbric
Cloudbric
Cyberwarzone
Cyberwarzone
Google DeepMind News
Google DeepMind News
C
Cyber Attacks, Cyber Crime and Cyber Security

博客园 - 烟雨客

Aspose.PDF跨平台问题解决 在aspx中写c# 在动态生成的HTML中执行JS AWS 2020 Innovate所有视频 sp_executesql 可動態傳入傳出參數 the input stream is not valid binary formate.... when call remoting 用SSISl连接PostgrsSQL Ubuntu 16.04 TLS下安装dotnet异常处理 客户端不刷新 在公网上布署Web Api的时候,不能调用,返回404 在公网(internet)上建立website时不能用http访问 ClickOnce发布后不能安装 从JPG中获取缩略图 MaraDNS与DeadWood一起配置为本地机器提供小型化DNS服务 await, anync The requested page cannot be accessed because the related configuration data for the page is invalid 404 Not Find When using Owin with OAuth Json序列化 关于获得本机Mac Address的方法
Socket服务端口长连接最多能支持多少?
烟雨客 · 2015-01-27 · via 博客园 - 烟雨客

答案是无限的。视服务端的资源而不同。

以前一直认为服务端在Accept客户端连接后,会开启一个新的端口与客户端建立链路,但这是错误的。事实上,一个连路是由Server IP+server Port + client IP + client port唯一定义。那么监听服务打开80时意味着这个服务打开了一个文件,当有client接入时,只要没有重复的链路,都会创建一个新链路,那么对于server端还是同一个端口,与客户端实现了同一个服务端口与不同的client建立了长/短连接的链路。

而以前在用C写程序的时候也是比较模糊,那时为了建立长连接,当接收客户端请求时,是要开启一个新线程与这个客户保持链路,但并不会开启一个新的Port. 开启一个新线程与开启一个新Port是不同概念,应该一个是监听Socket实例,这只有一个,其它的就是通信Socket,它可以是同一个server port,多个实例。端口不是一个实际的硬件口,也不是一个实际的软件对象,端口只是一个数字标记。