5 #ifndef SRC_IO_TCP_SERVER_H_
6 #define SRC_IO_TCP_SERVER_H_
8 #include <tbb/compat/condition_variable>
14 #include <boost/asio/ip/tcp.hpp>
15 #include <boost/intrusive_ptr.hpp>
16 #include <boost/scoped_ptr.hpp>
30 typedef boost::asio::ip::tcp::endpoint
Endpoint;
31 typedef boost::asio::ip::tcp::socket
Socket;
100 const std::string &md5_password);
102 const std::string &md5_password);
152 return lhs.get() < rhs.get();
155 typedef std::set<TcpSessionPtr, TcpSessionPtrCmp>
SessionSet;
163 const boost::system::error_code &error);
166 const boost::system::error_code &error);
182 boost::scoped_ptr<boost::asio::ip::tcp::acceptor>
acceptor_;
198 int prev = server->
refcount_.fetch_and_decrement();
boost::asio::ip::address IpAddress
static size_t GetServerCount()
static void DeleteServer(TcpServer *server)
static void AddServer(TcpServer *server)
static ServerManager< TcpServer, TcpServerPtr > impl_
tbb::atomic< int > refcount_
void GetTxSocketStats(SocketIOStats &socket_stats) const
uint8_t GetDscpValue(NativeSocketType fd) const
bool socket_open_failure() const
DISALLOW_COPY_AND_ASSIGN(TcpServer)
friend void intrusive_ptr_release(TcpServer *server)
tbb::interface5::condition_variable cond_var_
boost::asio::ip::tcp::endpoint Endpoint
std::multimap< Endpoint, TcpSession * > SessionMap
Endpoint LocalEndpoint() const
const std::string ToString() const
void GetRxSocketStats(SocketIOStats &socket_stats) const
boost::intrusive_ptr< TcpServer > TcpServerPtr
virtual void Connect(TcpSession *session, Endpoint remote)
std::unique_ptr< Socket > so_accept_
void GetRxSocketStats(SocketIOStats *socket_stats) const
int SetListenSocketMd5Option(uint32_t peer_ip, const std::string &md5_password)
std::set< TcpSessionPtr, TcpSessionPtrCmp > SessionSet
boost::scoped_ptr< boost::asio::ip::tcp::acceptor > acceptor_
int SetKeepAliveSocketOption(int fd, const SandeshConfig &sandesh_config)
friend void intrusive_ptr_add_ref(TcpServer *server)
bool RemoveSessionFromMap(Endpoint remote, TcpSession *session)
boost::asio::ip::tcp::socket::native_handle_type NativeSocketType
friend class BgpServerUnitTest
int SetListenSocketDscp(uint8_t value)
virtual TcpSession * AllocSession(Socket *socket)=0
void ConnectHandler(TcpServerPtr server, TcpSessionPtr session, const boost::system::error_code &error)
virtual Socket * accept_socket() const
virtual bool Initialize(unsigned short port)
virtual bool DisableSandeshLogMessages() const
void AcceptHandlerInternal(TcpServerPtr server, const boost::system::error_code &error)
TcpSession * GetSession(Endpoint remote)
int SetSocketOptions(const SandeshConfig &sandesh_config)
virtual TcpSession * CreateSession()
EventManager * event_manager()
void UpdateSessionsDscp(uint8_t dscp)
TcpServer(EventManager *evm)
bool socket_open_failure_
boost::intrusive_ptr< TcpSession > TcpSessionPtr
const io::SocketStats & GetSocketStats() const
virtual void DeleteSession(TcpSession *session)
int SetDscpSocketOption(NativeSocketType fd, uint8_t value)
void InsertSessionToMap(Endpoint remote, TcpSession *session)
void set_socket_open_failure(bool flag)
boost::asio::ip::tcp::socket Socket
bool HasSessionReadAvailable() const
virtual void set_accept_socket()
bool InitializeInternal(boost::asio::ip::tcp::endpoint localaddr)
void OnSessionClose(TcpSession *session)
void GetTxSocketStats(SocketIOStats *socket_stats) const
virtual void ConnectHandlerComplete(TcpSessionPtr session)
virtual bool AcceptSession(TcpSession *session)
size_t GetSessionCount() const
void SetName(Endpoint local_endpoint)
int SetMd5SocketOption(NativeSocketType fd, uint32_t peer_ip, const std::string &md5_password)
virtual void AcceptHandlerComplete(TcpSessionPtr session)
boost::intrusive_ptr< HttpClientSession > TcpSessionPtr
bool operator()(const TcpSessionPtr &lhs, const TcpSessionPtr &rhs) const
void intrusive_ptr_release(TcpServer *server)
void intrusive_ptr_add_ref(TcpServer *server)
boost::intrusive_ptr< TcpServer > TcpServerPtr