Sending Messages in a TCP Stream

前端 未结 5 1352
予麋鹿
予麋鹿 2021-01-19 07:36

TCP is stream-based, which means you send bytes without them necessarily being in a \"message\", so the receiver may get half a message or one and two thirds of messages.

5条回答
  •  时光取名叫无心
    2021-01-19 08:23

    You could use ØMQ (ZeroMQ) as your messaging infrastructure. ZeroMQ provides reliable message passing on top of TCP and other transport mechanisms. It has a C API and a comprehensive guide.

    Note that you would have to use an external library for all peers, but you said that is OK with you.

提交回复
热议问题