acl/lib_acl_cpp/include/acl_cpp/connpool/tcp_ipc.hpp

122 lines
3.6 KiB
C++
Raw Normal View History

#pragma once
#include "../stdlib/noncopyable.hpp"
2018-12-12 11:16:12 +08:00
namespace acl
{
class tcp_manager;
class tcp_pool;
class string;
/**
* tcp_manager
*
2018-12-12 11:16:12 +08:00
*/
class ACL_CPP_API tcp_ipc : public noncopyable
2018-12-12 11:16:12 +08:00
{
public:
tcp_ipc(void);
~tcp_ipc(void);
/**
*
* @param max {int} <= 0
2018-12-12 11:16:12 +08:00
* @return {tcp_ipc&}
*/
tcp_ipc& set_limit(int max);
/**
*
* @param ttl {int}
2018-12-12 11:16:12 +08:00
* @return {tcp_ipc&}
*/
tcp_ipc& set_idle(int ttl);
/**
*
* @param conn_timeout {int}
2018-12-12 11:16:12 +08:00
* @return {tcp_ipc&}
*/
tcp_ipc& set_conn_timeout(int conn_timeout);
/**
*
* @param timeout {int}
2018-12-12 11:16:12 +08:00
* @return {tcp_ipc&}
*/
tcp_ipc& set_rw_timeout(int timeout);
/**
* TCP
2018-12-12 11:16:12 +08:00
* @return {tcp_manager&}
*/
tcp_manager& get_manager(void) const;
/**
*
* @param addr {const char*} IP:PORT
2018-12-12 11:16:12 +08:00
* @return {tcp_ipc&}
*/
tcp_ipc& add_addr(const char* addr);
/**
*
*
*
* @param addr {const char*} IP:PORT
2018-12-12 11:16:12 +08:00
* @return {tcp_ipc&}
*/
tcp_ipc& del_addr(const char* addr);
/**
*
* @param addr {const char*} IP:PORT
2018-12-12 11:16:12 +08:00
* @return {bool}
*/
bool addr_exist(const char* addr);
/**
*
* @param addrs {std::vector<string>&}
2018-12-12 11:16:12 +08:00
*/
void get_addrs(std::vector<string>& addrs);
/**
*
* @param addr {const char*}
* @param {const void*}
* @param len {unsigned int}
* @param out {string*} NULL
* NULL
*
* @return {bool}
2018-12-12 11:16:12 +08:00
*/
bool send(const char* addr, const void* data, unsigned int len,
string* out = NULL);
/**
*
* @param {const void*}
* @param len {unsigned int}
* @param exclusive {bool} 广线线
*
* @param check_result {bool}
* @param nerr {unsigned *} NULL
* @return {size_t}
2018-12-12 11:16:12 +08:00
*/
size_t broadcast(const void* data, unsigned int len,
bool exclusive = true, bool check_result = false,
unsigned* nerr = NULL);
private:
tcp_manager* manager_;
int max_;
int ttl_;
int conn_timeout_;
int rw_timeout_;
bool send(tcp_pool&, const void*, unsigned int, string*);
};
} // namespace acl