RTBKit
0.9
Open-source framework to create real-time ad bidding systems.
|
#include <passive_endpoint.h>
Public Member Functions | |
PassiveEndpoint (const std::string &name) | |
int | init (PortRange const &portRange=PortRange(), const std::string &hostname="localhost", int threads=1, bool synchronous=true, bool nameLookup=true, int backlog=DEF_BACKLOG) |
virtual int | listen (PortRange const &portRange, const std::string &host, bool nameLookup=true, int backlog=DEF_BACKLOG) |
virtual void | closePeer () |
virtual std::string | hostname () const |
virtual int | port () const |
Public Attributes | |
boost::function < std::shared_ptr < ConnectionHandler >)> | onMakeNewHandler |
boost::function< void(std::string)> | onAcceptError |
Protected Member Functions | |
virtual void | associateHandler (const std::shared_ptr< TransportBase > &transport) |
virtual std::shared_ptr < ConnectionHandler > | makeNewHandler () |
virtual void | acceptError (const std::string &error) |
Protected Attributes | |
std::shared_ptr< Acceptor > | acceptor |
bool | nameLookup_ |
Friends | |
struct | AcceptorT |
An endpoint that listens for a connection that comes in on a port, before passing it off to all the standard stuff.
Definition at line 51 of file passive_endpoint.h.
virtual void Datacratic::PassiveEndpoint::associateHandler | ( | const std::shared_ptr< TransportBase > & | transport | ) | [inline, protected, virtual] |
Factory method to associate a connection with a transport.
Reimplemented from Datacratic::EndpointBase.
Definition at line 120 of file passive_endpoint.h.
virtual std::string Datacratic::PassiveEndpoint::hostname | ( | ) | const [inline, virtual] |
What host are we connected to?
Implements Datacratic::EndpointBase.
Definition at line 95 of file passive_endpoint.h.
int Datacratic::PassiveEndpoint::init | ( | PortRange const & | portRange = PortRange() , |
const std::string & | hostname = "localhost" , |
||
int | threads = 1 , |
||
bool | synchronous = true , |
||
bool | nameLookup = true , |
||
int | backlog = DEF_BACKLOG |
||
) |
Initialize the endpoint. If port is -1, then it will scan for ports until it finds one that's free. Returns the port number that it's listening on. Returns -1 on an error.
Will start up the given number of threads to help spread the work.
If synchronous is true, it will only return once there is at least one thread waiting for connections to come in. If synchronous is false, then it will return before there is anything listening and may eventually fail to make the connection. In this case, the notifyStartup() function will be called once everything has started up.
If threads is zero, then nothing will actually be done until a thread calls useThisThread() to do work.
Definition at line 40 of file passive_endpoint.cc.
virtual int Datacratic::PassiveEndpoint::listen | ( | PortRange const & | portRange, |
const std::string & | host, | ||
bool | nameLookup = true , |
||
int | backlog = DEF_BACKLOG |
||
) | [inline, virtual] |
Listen on the given port. If port is -1, then it should scan for a port and return that. Returns the port number.
Definition at line 80 of file passive_endpoint.h.
virtual int Datacratic::PassiveEndpoint::port | ( | ) | const [inline, virtual] |
What port are we listening on?
Implements Datacratic::EndpointBase.
Definition at line 101 of file passive_endpoint.h.
std::shared_ptr<Acceptor> Datacratic::PassiveEndpoint::acceptor [protected] |
Acceptor object to actually do the accepting.
Definition at line 117 of file passive_endpoint.h.
boost::function<void (std::string)> Datacratic::PassiveEndpoint::onAcceptError |
Object that can be overridden to deal with an accept error.
Definition at line 112 of file passive_endpoint.h.
boost::function<std::shared_ptr<ConnectionHandler>)> Datacratic::PassiveEndpoint::onMakeNewHandler |
Object that can be overridden to create the connection handler to be associated with the transport.
Definition at line 109 of file passive_endpoint.h.