1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
|
/*
* ACE reactor demonstration
*
* $Id: AcceptHandler.h 80826 2008-03-04 14:51:23Z wotte $
* Date: 26-Jan-2006
*/
#ifndef __ACCEPTHANDLER_H__
#define __ACCEPTHANDLER_H__
#include <ace/Event_Handler.h>
#include <ace/Reactor.h>
#include <ace/SOCK_Acceptor.h>
/**
* This accept handler is based on the provided solution from the ACE course.
*/
class AcceptHandler : public ACE_Event_Handler {
private:
/**
* The reactor to which the accept handler belongs.
*/
ACE_Reactor *mReactor;
/**
* The socket used for incoming conections.
*/
ACE_SOCK_Acceptor mAcceptor;
public:
/**
* @param reactor The reactor which will use this accept handler.
*/
AcceptHandler(ACE_Reactor *reactor = 0);
/**
* The destructor exists for tracing purposes.
*/
virtual ~AcceptHandler();
/**
* Open the listening socket and register the handler with the reactor.
*
* @return 0 on success, -1 on failure
*/
int open(void);
/**
* @name Overridden methods from the ACE_Event_Handler
*/
// @{
/**
* Provides the handle of mAcceptor.
*/
virtual ACE_HANDLE get_handle(void) const;
/**
* Create a read handler for the new connection and register that
* handler with the reactor.
*/
virtual int handle_input(ACE_HANDLE = ACE_INVALID_HANDLE);
/**
* Close the listening socket.
*/
virtual int handle_close(ACE_HANDLE, ACE_Reactor_Mask);
// @}
};
#endif /* __ACCEPTHANDLER_H__ */
|