在网络编程中,sockets/connections 的数量是有限制的,webserver 是如何超过这个限制的?

编程入门 行业动态 更新时间:2024-10-08 06:24:56
本文介绍了在网络编程中,sockets/connections 的数量是有限制的,webserver 是如何超过这个限制的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我已经开始探索使用 Socket 在 Linux 中的网络编程.我想知道 Yahoo、google 等网络服务器如何能够建立数百万/数十亿的连接.我相信核心只是套接字编程来访问远程服务器.如果是这种情况,那么数十亿人和数百万人如何能够连接到服务器.这意味着数十亿/数百万的套接字连接.这不可能吧?规范说最多只能有 5 个套接字连接.背后究竟有什么玄机?

I have started exploring on the network programming in Linux using Socket. I am wondering how come webservers like Yahoo, google, and etc are able to establish million/billions of connections. I believe the core is only socket programming to access the remote server. If that is the case then how come billion and millions of people are able to connect to the server. It means billions/millions of socket connection. This is not possible right? The spec says maximum 5 socket connections only. What is the mystery behind it?

您能否也谈谈这个 - API?

Can you also speak in terms of this - API?

listen(sock,5);

推荐答案

它并没有只说最多 5 个连接".您引用的 listen() 参数是积压,而不是连接总数.它指的是在应用程序通过 accept() 获取之前,TCP 将接受并保留在积压"队列() 上的传入连接数.

It doesn't 'say maximum 5 connections only'. The argument to listen() that you refer to is the backlog, not the total number of connections. It refers to the number of incoming connections that TCP will accept and hold on the 'backlog' queue() prior to the application getting hold of them via accept().

这篇关于在网络编程中,sockets/connections 的数量是有限制的,webserver 是如何超过这个限制的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-03-31 23:06:11,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/815324.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:是有   网络编程   数量   connections   sockets

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!