Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / ACE / examples / Reactor / TP_Reactor / ReadHandler.h
blobb3445ee643372b2c97152b33c51f58e3b28d8d56
1 /*
2 * ACE reactor demonstration
4 * Date: 26-Jan-2006
5 */
7 #ifndef __READHANDLER_H__
8 #define __READHANDLER_H__
10 #include <ace/Event_Handler.h>
11 #include <ace/SOCK_Stream.h>
13 /**
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 {
20 private:
21 /**
22 * The stream socket used for data exchange.
24 ACE_SOCK_Stream mStream;
26 /**
27 * The size of the data array.
29 int mDataSize;
31 /**
32 * The array containing the client's data.
34 char *mData;
36 /**
37 * The call counter to distinguish between first and second call.
39 int mCallCounter;
41 /**
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;
47 public:
48 /**
49 * Initialization.
51 ReadHandler();
53 /**
54 * Clean up data.
56 virtual ~ReadHandler();
58 /**
59 * Provide access to the internal stream socket.
61 ACE_SOCK_Stream &getStream();
63 /**
64 * @name Overridden methods from the ACE_Event_Handler
66 // @{
67 /**
68 * Provides the handle of mStream;
70 virtual ACE_HANDLE get_handle() const;
72 /**
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);
79 /**
80 * Deletes this instance of the read handler.
82 virtual int handle_close(ACE_HANDLE, ACE_Reactor_Mask);
83 // @}
86 #endif /* __READHANDLER_H__ */