【发布时间】:2010-06-17 23:34:48
【问题描述】:
首先我是网络新手,所以我可能会在这里说一些愚蠢的话。 考虑使用套接字的客户端-服务器应用程序(如果重要的话,.net 和 c#)。
- 客户端发送一些数据, 服务器对其进行处理并发送回 字符串。
- 客户端发送一些其他数据, 服务处理它,查询数据库 并送回数百 数据库中的项目
- 客户端发送一些其他类型的 数据和服务器通知一些 其他客户
。
我的问题是如何正确设置缓冲区大小以进行读/写操作。
我应该这样做:byte[] buff = new byte[client.ReceiveBufferSize] 吗?
I am thinking of something like this:
Client sends data to the server(and the server will follow the same pattern)
byte[] bytesToSend=new byte[2048] //2048 to be standard for any command send by the client
bytes 0..1 ->command type
bytes 1..2047 ->command parameters
byte[] bytesToReceive=new byte[8]/byte[64]/byte[8192] //switch(command type)
但是..当服务器通知客户端而不发送数据时会发生什么? 完成我想做的事情的正确方法是什么? 感谢阅读。
【问题讨论】:
标签: c# .net network-programming