Example #1
0
void aio_stream::hook_error()
{
	acl_assert(stream_);
	if (error_hooked_)
		return;

	error_hooked_ = true;
	handle_->increase();  // 增加异步流计数

	// 注册回调函数以截获关闭时的过程
	/*
	acl_aio_ctl(stream_,
		ACL_AIO_CTL_CLOSE_HOOK_ADD, close_callback, this,
		ACL_AIO_CTL_END);
	*/
	acl_aio_add_close_hook(stream_, close_callback, this);

	// 注册回调函数以截获超时时的过程
	/*
	acl_aio_ctl(stream_,
		ACL_AIO_CTL_TIMEO_HOOK_ADD, timeout_callback, this,
		ACL_AIO_CTL_END);
	*/
	acl_aio_add_timeo_hook(stream_, timeout_callback, this);
}
Example #2
0
http_client::http_client(acl::aio_socket_stream *client, int rw_timeout)
: conn_(client->get_astream())
, rw_timeout_(rw_timeout)
, content_length_(0)
{
	hdr_req_ = NULL;
	req_     = NULL;
	acl_aio_add_close_hook(conn_, on_close, this);
	acl_aio_add_timeo_hook(conn_, on_timeo, this);
}