开发者

Basic Client-Server Design for persistent connections?

开发者 https://www.devze.com 2022-12-26 03:05 出处:网络
Here\'s as far as I understand it: Client & Server make connection Cl开发者_运维技巧ient sends server data

Here's as far as I understand it:

  1. Client & Server make connection

  2. Cl开发者_运维技巧ient sends server data

  3. Server interprets data, sends client data

  4. So on, and so forth, until client sends disconnect signal.

I'm just wondering about implementation. Step 2 and 3 are confusing to me, maybe I'm over-complicating it. Is there anymore to interpreting the data than a giant switch statement?

Any good books on client/server design? Specifically talking about multithreaded servers, scalability, and message design (byte 1 = header info, byte 2 = blah blah, etc)? Specifically geared towards C++.


I woould think about packets, packet types, packets identifiers and storages of packet types handlers.

An idea is to only send a data in form of packets. Each packet holds its identifier(optional) and type at the beginning (length would be useful too) you have a bunch of packet handlers on each side of connection each handlers manages packets of corresponding type (reads and interprets). If you send a packet length you can even skip usupported types of packets allowing differrent client and server versions.

0

精彩评论

暂无评论...
验证码 换一张
取 消