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();
214 #endif // SRC_IO_TCP_SERVER_H_
virtual bool DisableSandeshLogMessages() const
int intrusive_ptr_add_ref(const AsPath *cpath)
static void AddServer(TcpServer *server)
void UpdateSessionsDscp(uint8_t dscp)
virtual void DeleteSession(TcpSession *session)
boost::asio::ip::tcp::socket Socket
tbb::atomic< int > refcount_
void GetRxSocketStats(SocketIOStats &socket_stats) const
tbb::interface5::condition_variable cond_var_
virtual void Connect(TcpSession *session, Endpoint remote)
friend void intrusive_ptr_add_ref(TcpServer *server)
std::set< TcpSessionPtr, TcpSessionPtrCmp > SessionSet
size_t GetSessionCount() const
boost::asio::ip::address IpAddress
TcpSession * GetSession(Endpoint remote)
virtual TcpSession * CreateSession()
void GetTxSocketStats(SocketIOStats *socket_stats) const
std::unique_ptr< Socket > so_accept_
friend void intrusive_ptr_release(TcpServer *server)
boost::intrusive_ptr< HttpClientSession > TcpSessionPtr
EventManager * event_manager()
static ServerManager< TcpServer, TcpServerPtr > impl_
std::multimap< Endpoint, TcpSession * > SessionMap
int SetKeepAliveSocketOption(int fd, const SandeshConfig &sandesh_config)
void GetRxSocketStats(SocketIOStats *socket_stats) const
void AcceptHandlerInternal(TcpServerPtr server, const boost::system::error_code &error)
bool operator()(const TcpSessionPtr &lhs, const TcpSessionPtr &rhs) const
Endpoint LocalEndpoint() const
virtual void AcceptHandlerComplete(TcpSessionPtr session)
void ConnectHandler(TcpServerPtr server, TcpSessionPtr session, const boost::system::error_code &error)
const std::string ToString() const
boost::intrusive_ptr< TcpServer > TcpServerPtr
int SetDscpSocketOption(NativeSocketType fd, uint8_t value)
virtual TcpSession * AllocSession(Socket *socket)=0
bool HasSessionReadAvailable() const
int SetSocketOptions(const SandeshConfig &sandesh_config)
friend class BgpServerUnitTest
boost::scoped_ptr< boost::asio::ip::tcp::acceptor > acceptor_
static void DeleteServer(TcpServer *server)
boost::intrusive_ptr< TcpServer > TcpServerPtr
TcpServer(EventManager *evm)
bool socket_open_failure_
static size_t GetServerCount()
bool InitializeInternal(boost::asio::ip::tcp::endpoint localaddr)
void OnSessionClose(TcpSession *session)
uint8_t GetDscpValue(NativeSocketType fd) const
void InsertSessionToMap(Endpoint remote, TcpSession *session)
void set_socket_open_failure(bool flag)
int SetListenSocketMd5Option(uint32_t peer_ip, const std::string &md5_password)
const io::SocketStats & GetSocketStats() const
virtual bool AcceptSession(TcpSession *session)
DISALLOW_COPY_AND_ASSIGN(TcpServer)
int SetListenSocketDscp(uint8_t value)
void GetTxSocketStats(SocketIOStats &socket_stats) const
void intrusive_ptr_release(const AsPath *cpath)
virtual bool Initialize(unsigned short port)
virtual void ConnectHandlerComplete(TcpSessionPtr session)
bool RemoveSessionFromMap(Endpoint remote, TcpSession *session)
virtual Socket * accept_socket() const
boost::asio::ip::tcp::socket::native_handle_type NativeSocketType
boost::asio::ip::tcp::endpoint Endpoint
int SetMd5SocketOption(NativeSocketType fd, uint32_t peer_ip, const std::string &md5_password)
void SetName(Endpoint local_endpoint)
bool socket_open_failure() const
virtual void set_accept_socket()
boost::intrusive_ptr< TcpSession > TcpSessionPtr