readme

来自「ace开发环境 用来开发网络程序 其运用了设计模式、多平台、C++等多种知识」· 代码 · 共 87 行

TXT
87
字号
ACE reactor demonstration=========================Martin KolleckTino Riethmuller1. IntroductionThis program demonstrates what we think is a bug in the ACE library. Theaffected component is the ACE_TP_Reactor. According to the documentation, thereactor ensures that only one of the handle_*() methods of an event handler iscalled at a time. Tino found this to be not true and I wrote this exampleprogram showing the behavior. I do not exclude the possibility that we areusing the ACE library in an unintended/wrong way. So comments on the code aswell as any other remarks are welcome.2. The programThe program consists of a client and a server. The general implementation istaken from the example solution to exercise 4c of the ACE course. The clientwill send a request to the server. This request is interpreted to be the sizeof the following data. The server allocates the memory required to hold theclient's data and then sends a confirmation to the client, that it mayproceed. The the client sends the large data chunk and the server againconfirms it.The client runs in a loop which can be configured to run indefinitely or apreviously set amount of times. The configuration i done from the commandline. To invoke the client type:    $ ./client size [count]<size> sets the size (in MiB) of the buffer sent to the server. Depending onthe systems, values between 60 and 100 have been used for testing. <count>determines how often the buffer is sent. If left out, the clients send thebuffer until interrupted.The server is started without arguments. Both programs will print a dot foreach successful connection. I found this an easy and unintrusive way of showingprogress whithout flooding the console too fast. This also makes it easier tosee when an error has occurred.3. Building the programThis example was created on a Linux box. You will need the environmentvariable ACE_ROOT set up to the location where ACE is installed. It might bepossible, that the path where the ACE libraries are found, needs to be adjustedin the Makefile.To compile simply type 'make' on the command prompt.    $ makeThis will create two executable files. One for the server and one for theclient. (named respectively)4. Running the programThe error seems to be of statistical nature. Occurring only under certainconditions (which I am not sure of, what they are). I successfully producedthe error on the four machines given below (architecture, ACE and compilerversion). I tested the program with localhost connections, as well as overa real network connection and could always reproduce the error.To detect the error I introduced a member variable to the read event handler.This counter is initialized to zero in the constructor. When handle_input() ofthe event handler is called, the counter is increased and decreased, whenhandle_input() returns. Before increasing the counter, It is compared to zero(which it should alway be, if only one invocation to handle_input() is madeat a time) and an error message is printed if it is not zero.To test for the error, I ran one instance of the server program and TWOinstances of the client program. The sizes of the buffers were between 60 and100 MiB and no count was given (running until stopped) The three Linux boxesshowed the error within one minute of starting both clients. For the Windowsbox I decreased the buffer size to 15 and 20 MiB (Windows does not seem to havevery performant localhost connectivity) and it took about half anhour until the error occurred the first time.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?