This article describes how to test a network service program with internal logic by using test harness.
The code for this article is shown in Http://code.google.com/p/muduo/source/browse/trunk/examples/multiplexer
Download Address: http://muduo.googlecode.com/files/muduo-0.2.0-alpha.tar.gz SHA1 checksum: 75a09a82f96b583004876e95105c679e64c95715
Cloud Wind in his blog mentioned the game to connect the server's functional requirements (search "practicing project"), I used C + + to achieve these requirements, and to write a supporting automated test harness, as an example of Muduo network library.
Note: The code presented in this article only realizes the basic functional requirements, does not consider the security, also does not have the special optimization performance, does not fit for the real on-line operation on the public net swims the connection server.
Functional Requirements
This connection server brings together multiple customer connections into an internal TCP connection, which acts as a "data string and transform", allowing backend logical servers to concentrate on the business without having to take into account the concurrency of multiple connections. The following is a block diagram of the system:
The role of this connection server is similar to the data selector (multiplexer) in the digital circuit, so I named it multiplexer. (In fact, io-multiplexing also takes this meaning to allow a thread-of-control to selectively handle multiple IO file descriptors.) )
(The above image is from Wikipedia, is public domain copyright)