2 * ACE reactor demonstration
7 #ifndef __READHANDLER_H__
8 #define __READHANDLER_H__
10 #include <ace/Event_Handler.h>
11 #include <ace/SOCK_Stream.h>
14 * This read handler is created by the accept handler and handles all the data
15 * exchange between client and server. The client makes two requests to the
16 * server. The first asks the server to create a buffer which will hold the
17 * data sent in the second call.
19 class ReadHandler
: public ACE_Event_Handler
{
22 * The stream socket used for data exchange.
24 ACE_SOCK_Stream mStream
;
27 * The size of the data array.
32 * The array containing the client's data.
37 * The call counter to distinguish between first and second call.
42 * Count the numer of invocations of handle_*(). According to the
43 * docs, there should be only one invocation at any given time.
45 int mInvocationCounter
;
56 virtual ~ReadHandler();
59 * Provide access to the internal stream socket.
61 ACE_SOCK_Stream
&getStream();
64 * @name Overridden methods from the ACE_Event_Handler
68 * Provides the handle of mStream;
70 virtual ACE_HANDLE
get_handle() const;
73 * Handles the data excahnge between client and server. On the first
74 * invocation, mData is allocated to the requested size and on the
75 * second invocation, that buffer is filled with the client's data.
77 virtual int handle_input(ACE_HANDLE
= ACE_INVALID_HANDLE
);
80 * Deletes this instance of the read handler.
82 virtual int handle_close(ACE_HANDLE
, ACE_Reactor_Mask
);
86 #endif /* __READHANDLER_H__ */