42 template<
class SERVICE_HANDLER,
class PEER_ACCEPTOR>
68 virtual int close (
void);
134 #define SH SERVICE_HANDLER 135 #define PA PEER_ACCEPTOR 141 template<
class SH,
class PA>
147 trace(
"Acceptor::Acceptor");
150 template<
class SH,
class PA>
155 trace(
"Acceptor::~Acceptor");
158 template<
class SH,
class PA>
163 trace(
"Acceptor::close");
168 template<
class SH,
class PA>
173 trace(
"Acceptor::handle_close");
180 DL ((
REACT,
"Deleted acceptor \"%s\"\n",
get_id ().c_str ()));
185 template<
class SH,
class PA>
186 inline SERVICE_HANDLER*
190 trace(
"Acceptor<>::makeServiceHandler");
192 return new SERVICE_HANDLER (sock_);
195 template<
class SH,
class PA>
200 trace(
"Acceptor::acceptServiceHandler");
203 return new_socket_ ? 0 : -1;
206 template<
class SH,
class PA>
int 210 trace(
"Acceptor::activateServiceHandler");
216 if (sh->open () < 0) {
222 template<
class SH,
class PA>
int 226 trace(
"Acceptor::open");
239 DL((
TRACE,
"Opened acceptor for fd=%d\n",
250 template <
class SH,
class PA>
int 254 trace(
"Acceptor<>::handle_read");
257 timeval poll = {0, 0};
276 while ((::select (fd+1, &mask, NULL, NULL, &poll) == 1));
virtual int handle_close(int fd)
Callback invoked by Reactor if PEER_ACCEPTOR stream went bad, or Reactor has been commanded to stop e...
bool registerIOHandler(EventHandler *eh_, handler_t fd_, EventType et_=RWE_EVENTS)
Register I/O Event handler with Reactor.
Acceptor(Reactor *r_)
Default constructor.
#define trace(s)
trace() is used to trace function call chain in C++ program.
virtual int acceptServiceHandler(PEER_ACCEPTOR *&new_socket_)
Default strategy is to accept new connection.
bool setFd(handler_t fd_)
Set flag (ON) for the argument fd.
virtual int activateServiceHandler(PEER_ACCEPTOR *new_socket_)
Defines the concurrency strategy.
virtual SA * getAddress() const =0
Retrieve pointer to the address structure.
This abstract class provides generic interface for processing services.
virtual int open(const Address &local_addr_)
Initialize listener endpoint and Acceptor with Reactor.
virtual ~Acceptor()
Do-nothing destructor.
#define DL(X)
A macro for writing debug message to the Logger.
std::string get_id() const
Retrieve EventHandler ID.
Class Reactor/PrioriyQueue messages.
void reset()
Reset every bit in the set (OFF).
int handle_read(int fd)
Callback invoked by Reactor when new connection requests is detected.
An abstract interface for handling I/O events, timers, and such.
Address is an abstraction for INET or UNIX-domain address data type.
An abstraction to message logging facility.
An implementation of Reactor pattern.
virtual int close(void)
Close PEER_ACCEPTOR stream.
PEER_ACCEPTOR m_listenSocket
Underlying communication stream.
Reactor * m_reactor
Reactor to use.
Notify when there will be at least 1 byte available for reading from IO channel without blocking ...
virtual SERVICE_HANDLER * makeServiceHandler(PEER_ACCEPTOR *sock_)
Defines creation strategy for ServiceHandler.