简体   繁体   English

linux unix sockets vs tcp sockets发送缓冲区大小

[英]linux unix sockets vs tcp sockets send buffer size

I am comparing how many bytes a send call can transfer when a socket is tcp and when it is unix socket. 我正在比较套接字是tcp时和unix套接字时,发送调用可以传输多少字节。

For unix domain socket the number is always 219264,but for TCP this number is much higher.Why is this difference? 对于unix域套接字,该数字始终为219264,但是对于TCP,此数字高得多。为什么会有这种差异? Both the programs are executed in the same machine 两个程序都在同一台机器上执行

Note:sockets are in non blocking mode 注意:套接字处于非阻塞模式

checked the buffer size,these are the values 检查缓冲区大小,这些是值

unix domain socket Unix域套接字

receive buffer size =212992
send buffer size =212992

TCP socket TCP套接字

receive buffer size =1062000
send buffer size =2626560

can someone explain me why is this difference? 谁能解释我为什么有这个区别?

The tcp buffer is used for packages which have been sent but not acknowledged by the other end yet and for packages which have been received out of order and are waiting for delayed packages to arrive before presented to the application. tcp缓冲区用于已发送但尚未被另一端确认的程序包,以及已乱序接收并等待延迟的程序包到达后再提供给应用程序的程序包。 Of course packages will also stay in the buffer as long as the consuming application doesn't read() the data. 当然,只要使用的应用程序不read()数据,程序包也将保留在缓冲区中。

Over UNIX sockets, packages which are waiting for ACK, or the order of packages is not an issue, therefore the buffer can be smaller. 在UNIX套接字上,等待ACK的包或包的顺序不是问题,因此缓冲区可以较小。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM