BlueSocket
BlueSocket copied to clipboard
Tcp Incomplete receiving data
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

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.