Unfortunately, I cannot use the send or recv commands because of buffering issues with TCP. It has to be gets/puts which is quite unfortunate, but I have no other simple workaround.