chenshuo / muduo

Event-driven network library for multi-threaded Linux server in C++11
https://github.com/chenshuo/muduo
Other
14.7k stars 5.15k forks source link

client send 4096 bytes to muduo server, server only receive 2805 bytes #534

Closed Allenhe123 closed 2 years ago

Allenhe123 commented 2 years ago

Linux distro and version? x86 or ARM? 32-bit or 64-bit?

ARM

Branch (cpp98/cpp11/cpp17) and version of muduo?

cpp17

Version of cmake, gcc and boost? (If not from distro.)

cmakle

Description: server: changed from muduo's pingpong_server example client: a python program, send a file to server. If the client sent 4096 bytes at a time, server will only received 2805 bytes. If the client sent 1024 bytes at a time, it is ok.

chenshuo commented 2 years ago

First of all, TCP is a byte stream protocol.

Ref. Effective TCP/IP Programming: 44 Tips to Improve Your Network Programs Tip 6 : Remember That TCP Is a Stream Protocol

TCP is a stream protocol. This means that data is delivered to a recipient as a stream of bytes with no inherent notion of “message” or “message boundary.” In this respect, reading TCP data is much like reading data from a serial port—one never knows how many bytes will be returned on a given call to read.