0

I would like to know how to manage read and write buffers in a many clients / one server architecture.

My server is asynchronous.

My exact questions are:

  • Do I need to have one read buffer per client connected, or one for the server globally ? Why ? (to avoid data crushing if multiple clients write to the server simultaneously for example).
  • Same question with write buffer.
  • If my server wasn't asynchronous, would it change any of the answers ?

Thank you in advance for your responses,

Flo

4

1 回答 1

1

我需要为每个连接的客户端设置一个读取缓冲区,还是需要一个用于全局服务器的读取缓冲区?

每个客户端一个,因为您将获得部分读取,并且您需要继续阅读以组装整个消息:您希望所有数据在一个位置相邻。

与写缓冲区相同的问题。

每个客户一个,因为您可以获得简短的写入。

如果我的服务器不是异步的,它会改变任何答案吗?

不。

于 2013-10-03T00:16:45.870 回答