From mboxrd@z Thu Jan 1 00:00:00 1970 From: michi1@michaelblizek.twilightparadox.com (michi1 at michaelblizek.twilightparadox.com) Date: Fri, 23 Sep 2016 18:04:48 +0200 Subject: What causes a recv syscall for a socket to sometimes return less than the request len? In-Reply-To: References: Message-ID: <20160923160448.GA3415@grml> To: kernelnewbies@lists.kernelnewbies.org List-Id: kernelnewbies.lists.kernelnewbies.org Hi! On 17:20 Wed 21 Sep , Daniel Ellis wrote: > Howdy, > > I understand that data fragmentation happens across TCP packets, and in my > case that is what is happening. The packets I'm seeing usually run around > 1450 in length, and are always cut into two packets at the 1400 mark. This > works fine most of the time, since the call to recv is being passed a len > of 4096 (via Python's socket.recv, which I'm assuming is just a wrapper > around the system call). But sometimes I'll get all of the data I request, > even across TCP packet boundaries (so the full 1450 bytes), and other > times, it stops at a single packet, at which point I need to make another > recv call. The recv() call currently returns: - as soon as there is some data in the receive queue - all the data which is in the queue, up your buffer size. -Michi -- programing a layer 3+4 network protocol for mesh networks see http://michaelblizek.twilightparadox.com