Linux上套接字中的缓冲如何工作 [英] How the buffering work in socket on linux

查看:62
本文介绍了Linux上套接字中的缓冲如何工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在Linux上的套接字中使用缓冲? 即如果服务器未读取套接字,而客户端继续发送数据. 那么会发生什么呢?套接字的缓冲区有多大?客户端会知道,以便它将停止发送吗?

How does buffering work with sockets on Linux? i.e. if the server does not read the socket and the client keeps sending data. So what will happen? How big is the socket's buffer? And will the client know so that it will stop sending?

推荐答案

对于UDP套接字客户端永远不会知道-服务器端将在接收缓冲区填满后才开始丢弃数据包.

For UDP socket client will never know - the server side will just start dropping packets after the receive buffer is filled.

TCP实现了 流控制 .服务器的内核将逐渐减小窗口,因此客户端将能够发送越来越少的数据.在某个时候,窗口将降为零.此时,客户端将填满其发送缓冲区,并从send(2)接收错误.

TCP, on the other hand, implements flow control. The server's kernel will gradually reduce the window, so the client will be able to send less and less data. At some point the window will go down to zero. At this point the client fills up its send buffer and receives an error from the send(2).

这篇关于Linux上套接字中的缓冲如何工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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