I/O Model Consideration

By now you might be wondering how to choose the I/O model you should use when designing your application. As we've mentioned, each model has its strengths and weaknesses. All of the I/O models do require fairly complex programming compared with developing a simple blocking-mode application with many servicing threads. We offer the following suggestions for client and server development.

I/O模型

     到现在,我们会思考如何为应用程序选择合适的I/O模型。注意到每种模型都有其优缺点。采用阻塞模型的应用需要多个线程。而与阻塞模型相比,其它I/O模型在程序上更复杂。对于客户端和服务器的I/O模型选择我们给出如下建议。

Client Development

When you are developing a client application that manages one or more sockets, we recommend using overlapped I/O or WSAEventSelect over the other I/O models for performance reasons. But, if you are developing a Windows-based application that manages window messages, the WSAAsyncSelect model might be a better choice because WSAAsyncSelect lends itself to the Windows message model, and your application is already set up for handling messages.

客户端开发

    当需要开发的客户端程序需要管理一个或多个socket时,基于性能的考虑,推荐使用overlapped I/O 或WSAEventSelect 模式。但是,如果你在开发基于windows的应用程序,需要管理windows消息时,建议采用WSAAsyncSelect 模式,因为它提供了windows消息处理的机制。

Server Development

When you are developing a server that processes several sockets at a given time, we recommend using overlapped I/O over the other I/O models for performance reasons. However, if you expect your server to service a large number of I/O requests at any given time, you should consider using the I/O completion port model for even better performance.

服务器开发

     如果服务器在某时刻只用处理几个socket,推荐采用overlapped I/O模型。而如果希望服务器在任何时间需要服务大量的I/O请求,那么基于性能的考虑,需要采用I/O completion port(完成端口)模型