在网络编程中,套接字/连接数有限制,网络服务器如何超过此限制? [英] In network programming, there is a limit to number of sockets/connections, how webserver exceeds this limit?

查看:182
本文介绍了在网络编程中,套接字/连接数有限制,网络服务器如何超过此限制?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经开始探索使用Socket的Linux网络编程.我想知道雅虎,谷歌等网络服务器如何能够建立百万/十亿个连接.我相信核心只是用于访问远程服务器的套接字编程.如果真是这样,那么数十亿人能够连接到服务器.这意味着数十亿/数以百万计的套接字连接.这不可能吗?规范说最多只能有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之前,TCP将接受并保留在"backlog" queue()中的传入连接数.

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().

这篇关于在网络编程中,套接字/连接数有限制,网络服务器如何超过此限制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆