add send method in tcp_pool class.

This commit is contained in:
zhengshuxin 2017-08-08 23:27:37 +08:00
parent 2e7167bfd7
commit ffcfd87d26
4 changed files with 26 additions and 2 deletions

View File

@ -5,6 +5,7 @@
namespace acl
{
class string;
class connect_client;
class ACL_CPP_API tcp_pool : public connect_pool
@ -13,6 +14,8 @@ public:
tcp_pool(const char* addr, size_t count, size_t idx = 0);
virtual ~tcp_pool(void);
bool send(const void* data, unsigned int len, string* out = NULL);
protected:
// @override
virtual connect_client* create_connect(void);

View File

@ -18,7 +18,7 @@ namespace acl
class socket_stream;
class string;
class tcp_reader
class ACL_CPP_API tcp_reader
{
public:
tcp_reader(socket_stream& conn);

View File

@ -22,4 +22,25 @@ connect_client* tcp_pool::create_connect(void)
return conn;
}
bool tcp_pool::send(const void* data, unsigned int len,
string* out /* = NULL */)
{
tcp_client* conn = (tcp_client*) this->peek();
if (conn == NULL)
{
logger_error("no connection available, addr=%s",
this->get_addr());
return false;
}
if (conn->send(data, len, out) == false)
{
this->put(conn, false);
return false;
}
this->put(conn);
return true;
}
} // namespace acl

View File

@ -212,7 +212,7 @@ static void polarssl_dll_load(void)
# define __pkey_free ::rsa_free
# endif
# define __entropy_init ::entropy_init
# define __entropy_init ::entropy_init
# define __ssl_list_ciphersuites ::ssl_list_ciphersuites
# define __ssl_set_ciphersuites ::ssl_set_ciphersuites
# define __ssl_set_session_cache ::ssl_set_session_cache