BlueSocket icon indicating copy to clipboard operation
BlueSocket copied to clipboard

Tcp Incomplete receiving data

Open ShineYangGod opened this issue 3 years ago • 1 comments

After connecting to TCP, I waited to receive data after sending data, and found that only half of the received data was received. How to solve the problem of not receiving half of the data received 截屏2022-05-18 15 40 54

ShineYangGod avatar May 18 '22 08:05 ShineYangGod

Unlike websockets, read and writes for TCP sockets are not guaranteed to be of any particular size and may chop your message such that you need multiple read's to get the full message. You can find similar discussions in Issue 204 and Issue 176.

I recently made a PacketProcessor for Swift that may help in managing your buffers in these situations. I have some tutorials, but I do not yet have an example that demonstrates using it in conjunction with raw sockets.

dannys42 avatar May 22 '22 17:05 dannys42