mirror of
https://gitee.com/acl-dev/acl.git
synced 2024-12-14 08:50:53 +08:00
9697f95b8f
This reverts commit 15d999759e
.
34 lines
638 B
C++
34 lines
638 B
C++
#include "acl_stdafx.hpp"
|
|
#ifndef ACL_PREPARE_COMPILE
|
|
#include "acl_cpp/stream/socket_stream.hpp"
|
|
#include "acl_cpp/connpool/tcp_sender.hpp"
|
|
#endif
|
|
|
|
namespace acl
|
|
{
|
|
|
|
tcp_sender::tcp_sender(socket_stream& conn)
|
|
: conn_(&conn)
|
|
{
|
|
v2_ = (struct iovec*) acl_mymalloc(sizeof(struct iovec) * 2);
|
|
}
|
|
|
|
tcp_sender::~tcp_sender(void)
|
|
{
|
|
acl_myfree(v2_);
|
|
}
|
|
|
|
bool tcp_sender::send(const void* data, unsigned int len)
|
|
{
|
|
unsigned int n = htonl(len);
|
|
|
|
v2_[0].iov_base = &n;
|
|
v2_[0].iov_len = sizeof(n);
|
|
v2_[1].iov_base = (void*) data;
|
|
v2_[1].iov_len = len;
|
|
|
|
return conn_->writev(v2_, 2) > 0;
|
|
}
|
|
|
|
} // namespace acl
|