A public forum for discussing the design of software, from the user interface to the code architecture. Now closed.
For anyone who has designed a TCP/IP server application on Windows and used AcceptEx, what methods have you used to manage the creation of client sockets?
I have been thinking about this and it seems like the best strategy would probably depend on the protocol. For example, I was thinking that for a "stateless" protocol such as HTTP, you might do well to simply allocate a fixed number of sockets at startup time and just use them over and over again. This would limit your ability to handle requests concurrently, but since each transaction would be short and sweet, that might not be a problem.
On the other hand, it seems as though if the protocol called for a persistent connection over the lifetime of a client's interaction with the server, you might want to implement some scheme that would be able to allocate more sockets as they were required.
However, it occurred to me that in case 2, the benefits of AcceptEx would be harder to see because the overall connection time would be large compared to the overhead of a call to the standard Accept function.
Do you think I'm on the right track in terms of my thinking? I'm sort of new to this stuff.
Lastly, any recommendations on books that describe the development of highly scalable TCP/IP based servers?
If you want highly scalable, you might take a look at Erlang. See http://www.sics.se/~joe/apachevsyaws.html for a performace comparison of the Apache web server vs. the Erlang-based YAWS.
Sunday, August 20, 2006
I would allocate a fixed number of client sockets at startup and expand as needed. Unless you own both ends of a connection and everything in between you can't assume a transaction will complete in the minimum amount of time. There's slow dialup and wireless connections and network congestion to consider. HTTP also has keep alive which is a must if you're shooting for scalability. That will lengthen connection time.
AcceptEx could still be of benefit with a persistent connection protocol. It integrates well with the other async i/o calls so you can maintain a consistent architecture.
For high performance, you want to use IOCP.
Two books I have found helpful:
Network Programming for Microsoft Windows, Second Edition
Programming Server-Side Applications for Microsoft Windows 2000
Here is an example of a web server using C++/MFC and IOCP.
This topic is archived. No further replies will be accepted.Other recent topics
Powered by FogBugz