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

推荐订阅源

Forbes - Security
Forbes - Security
T
Tailwind CSS Blog
Hugging Face - Blog
Hugging Face - Blog
Blog — PlanetScale
Blog — PlanetScale
WordPress大学
WordPress大学
aimingoo的专栏
aimingoo的专栏
Y
Y Combinator Blog
U
Unit 42
I
InfoQ
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
V
Visual Studio Blog
B
Blog RSS Feed
Vercel News
Vercel News
F
Fortinet All Blogs
Know Your Adversary
Know Your Adversary
T
Troy Hunt's Blog
博客园 - 【当耐特】
MongoDB | Blog
MongoDB | Blog
大猫的无限游戏
大猫的无限游戏
A
About on SuperTechFans
Jina AI
Jina AI
小众软件
小众软件
T
Threatpost
有赞技术团队
有赞技术团队
人人都是产品经理
人人都是产品经理
The Hacker News
The Hacker News
T
The Exploit Database - CXSecurity.com
C
CXSECURITY Database RSS Feed - CXSecurity.com
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Microsoft Azure Blog
Microsoft Azure Blog
Recent Announcements
Recent Announcements
酷 壳 – CoolShell
酷 壳 – CoolShell
Scott Helme
Scott Helme
B
Blog
腾讯CDC
Last Week in AI
Last Week in AI
P
Proofpoint News Feed
S
Schneier on Security
N
News and Events Feed by Topic
Microsoft Security Blog
Microsoft Security Blog
K
Kaspersky official blog
G
Google Developers Blog
T
Tor Project blog
PCI Perspectives
PCI Perspectives
S
Secure Thoughts
Google Online Security Blog
Google Online Security Blog
Latest news
Latest news
Google DeepMind News
Google DeepMind News
MyScale Blog
MyScale Blog
罗磊的独立博客

博客园 - 烟雨客

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,多个实例。端口不是一个实际的硬件口,也不是一个实际的软件对象,端口只是一个数字标记。