Data become corrupted through tcp

changed code as you said, but it's not solving the problem, the s value is always 5, and its read exactly 5 bytes, but their values doesn't match
it's the last 5 sent buffers

[1, 30, 231, 31, 189]
[1, 157, 212, 34, 189]
[1, 102, 206, 37, 189]
[1, 184, 39, 39, 189]
[1, 52, 148, 38, 189]

and its is the last 5 received

[1, 2, 249, 127, 189]
[1, 29, 164, 126, 189]
[1, 27, 108, 122, 189]
[1, 109, 218, 123, 189]
[1, 102, 169, 117, 189]

here is a gist with code