The Web-based open-source C/s server framework is still relatively small. Recently studied Spserver, which used a lot of design patterns, the purpose of using the design pattern is to separate things and mutable things and packaging, to avoid the future modification of the code, the application of design patterns in the book is "Closed to change, open to expansion", But misuse of design patterns can complicate simple questions.
Spserver code is relatively small, it is easier to understand, if only to do a simple echo server, Spserver can give the novice a quick framework to build a server.
After testing with VLD, it was found that Spserver had a lot of memory leaks. and the Msgqueue_destroy function causes the thread to block and the program does not end normally.
The semi-synchronous half-Asynchronous pattern inside the Spserver is equivalent to the main thread responsible for all data sending and receiving, and the worker thread is responsible for logic. The main thread communicates with the worker thread through Message Queuing. After the main thread receives the data, notifies the worker thread, has the data, the worker thread carries on the message parsing and processing, sends the data to send the queue, then notifies the main thread, has the data, you go to send the.
This model can deal with the complexity of logic, long processing time, the need to send and receive less data is more appropriate situation. But if you need to deal with a file server like this, IO data a lot, but the logic is very simple server, it is not appropriate, the main thread will become a bottleneck, that is, IO will become a bottleneck.
In addition, Spserver does not implement code that connects other servers as a client, requiring users to implement their own connections to other servers.
I am now encapsulating an open source server framework, which is more general and broader than Spserver, and will encapsulate a relatively complete set of implementations based on the system architecture of the game server, from the database proxy server, the login server, the hall server, the game server, the gateway server and other framework processing.
http://blog.csdn.net/langeldep/article/details/5607110
Research and analysis of Spserver Open source server framework