You should just send 32 bits specifying how much you received:
If you received 4096 bytes you would send $chr(0) $+ $chr(0) $+ $chr(16) $+ $chr(0)


$input(Me like stars, You too?)