简体   繁体   中英

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.

For unix domain socket the number is always 219264,but for TCP this number is much higher.Why is this difference? 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

receive buffer size =212992
send buffer size =212992

TCP socket

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. Of course packages will also stay in the buffer as long as the consuming application doesn't read() the data.

Over UNIX sockets, packages which are waiting for ACK, or the order of packages is not an issue, therefore the buffer can be smaller.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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