Fix 2 small bugs with resending tcp data

Found problem when returning to send TCP data on a second pass:
- pkt was being written to wrong buffer
- size_t comparison was failing, cast used instead