Friday, 15 August 2014

Java TCP. How to affirm your received packet is a complete data structure? -



Java TCP. How to affirm your received packet is a complete data structure? -

i have programme listens , sends on tcp socket.

the problem i'm having send packet , breaks pieces. listening tcp socket class thinks first piece comes in entire payload.

what typical approach people take when programming tcp connections?

you cannot assume first piece entire payload. have maintain reading off socket until of it.

there 2 options:

option 1 mark end of messages (data structures). listener keeps reading until gets end-of-message marker.

option 2 send length of message or info construction before send actual data. listener keeps reading until read bytes.

java tcp

No comments:

Post a Comment