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

133 lines
3.6 KiB
C++
Raw Normal View History

/**
* Copyright (C) 2017-2018
* All rights reserved.
*
* AUTHOR(S)
* Zheng Shuxin
* E-mail: zhengshuxin@qiyi.com
*
* VERSION
* Tue 08 Aug 2017 03:09:21 PM CST
*/
#pragma once
namespace acl
{
class tcp_manager;
class tcp_pool;
class string;
/**
* tcp_manager
*
*/
class ACL_CPP_API tcp_ipc
{
public:
tcp_ipc(void);
~tcp_ipc(void);
/**
*
* @param max {int} <= 0
* @return {tcp_ipc&}
*/
tcp_ipc& set_limit(int max);
/**
*
* @param ttl {int}
* @return {tcp_ipc&}
*/
tcp_ipc& set_idle(int ttl);
/**
*
* @param conn_timeout {int}
* @return {tcp_ipc&}
*/
tcp_ipc& set_conn_timeout(int conn_timeout);
/**
*
* @param timeout {int}
* @return {tcp_ipc&}
*/
tcp_ipc& set_rw_timeout(int timeout);
/**
* TCP
* @return {tcp_manager&}
*/
tcp_manager& get_manager(void) const;
/**
*
* @param addr {const char*} IP:PORT
* @return {tcp_ipc&}
*/
tcp_ipc& add_addr(const char* addr);
/**
*
*
*
* @param addr {const char*} IP:PORT
* @return {tcp_ipc&}
*/
tcp_ipc& del_addr(const char* addr);
/**
*
* @param addr {const char*} IP:PORT
* @return {bool}
*/
bool addr_exist(const char* addr);
/**
*
* @param addrs {std::vector<string>&}
*/
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}
*/
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}
*/
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