acl
3.5.3.0
|
本文件中定义了关于 ACL_ASTREAM 异步通信流操作的类型说明及函数接口. 更多...
#include "../stdlib/acl_define.h"
#include <stdarg.h>
#include "../stdlib/acl_stdlib.h"
#include "../event/acl_events.h"
#include "../net/acl_netdb.h"
类 | |
struct | ACL_ASTREAM |
类型定义 | |
typedef struct ACL_AIO | ACL_AIO |
typedef struct ACL_ASTREAM | ACL_ASTREAM |
typedef int(* | ACL_AIO_READ_FN) (ACL_ASTREAM *astream, void *context, char *data, int dlen) |
typedef int(* | ACL_AIO_NOTIFY_FN) (ACL_ASTREAM *astream, void *context) |
typedef int(* | ACL_AIO_WRITE_FN) (ACL_ASTREAM *astream, void *context) |
typedef int(* | ACL_AIO_ACCEPT_FN) (ACL_ASTREAM *cstream, void *context) |
typedef int(* | ACL_AIO_LISTEN_FN) (ACL_ASTREAM *sstream, void *context) |
typedef int(* | ACL_AIO_CONNECT_FN) (ACL_ASTREAM *cstream, void *context) |
typedef struct ACL_ASTREAM_CTX | ACL_ASTREAM_CTX |
typedef int(* | ACL_AIO_CONNECT_ADDR_FN) (const ACL_ASTREAM_CTX *ctx) |
typedef int(* | ACL_AIO_TIMEO_FN) (ACL_ASTREAM *astream, void *context) |
typedef int(* | ACL_AIO_CLOSE_FN) (ACL_ASTREAM *astream, void *context) |
函数 | |
ACL_API int | acl_astream_get_status (const ACL_ASTREAM_CTX *ctx) |
ACL_API const ACL_SOCKADDR * | acl_astream_get_ns_addr (const ACL_ASTREAM_CTX *ctx) |
ACL_API const ACL_SOCKADDR * | acl_astream_get_serv_addr (const ACL_ASTREAM_CTX *ctx) |
ACL_API ACL_ASTREAM * | acl_astream_get_conn (const ACL_ASTREAM_CTX *ctx) |
ACL_API void * | acl_astream_get_ctx (const ACL_ASTREAM_CTX *ctx) |
ACL_API ACL_AIO * | acl_aio_create (int event_mode) |
ACL_API ACL_AIO * | acl_aio_create2 (int event_mode, unsigned int nMsg) |
ACL_API ACL_AIO * | acl_aio_create3 (ACL_EVENT *event) |
ACL_API void * | acl_aio_dns (ACL_AIO *aio) |
ACL_API int | acl_aio_set_dns (ACL_AIO *aio, const char *dns_list, int timeout) |
ACL_API void | acl_aio_del_dns (ACL_AIO *aio, const char *dns_list) |
ACL_API void | acl_aio_clear_dns (ACL_AIO *aio) |
ACL_API void | acl_aio_free (ACL_AIO *aio) |
ACL_API void | acl_aio_free2 (ACL_AIO *aio, int keep) |
ACL_API void | acl_aio_loop (ACL_AIO *aio) |
ACL_API int | acl_aio_last_nready (ACL_AIO *aio) |
ACL_API void | acl_aio_check (ACL_AIO *aio) |
ACL_API ACL_EVENT * | acl_aio_event (ACL_AIO *aio) |
ACL_API int | acl_aio_event_mode (ACL_AIO *aio) |
ACL_API int | acl_aio_get_keep_read (ACL_AIO *aio) |
ACL_API void | acl_aio_set_keep_read (ACL_AIO *aio, int onoff) |
ACL_API int | acl_aio_get_delay_sec (ACL_AIO *aio) |
ACL_API int | acl_aio_get_delay_usec (ACL_AIO *aio) |
ACL_API void | acl_aio_set_delay_sec (ACL_AIO *aio, int delay_sec) |
ACL_API void | acl_aio_set_delay_usec (ACL_AIO *aio, int delay_usec) |
ACL_API void | acl_aio_set_check_inter (ACL_AIO *aio, int check_inter) |
ACL_API void | acl_aio_set_rbuf_size (ACL_AIO *aio, int rbuf_size) |
ACL_API void | acl_aio_set_accept_nloop (ACL_ASTREAM *astream, int nloop) |
ACL_API ACL_AIO * | acl_aio_handle (ACL_ASTREAM *stream) |
ACL_API void | acl_aio_set_ctx (ACL_ASTREAM *stream, void *ctx) |
ACL_API void * | acl_aio_get_ctx (ACL_ASTREAM *stream) |
ACL_API ACL_ASTREAM * | acl_aio_open (ACL_AIO *aio, ACL_VSTREAM *stream) |
ACL_API void | acl_aio_iocp_close (ACL_ASTREAM *astream) |
ACL_API ACL_VSTREAM * | acl_aio_cancel (ACL_ASTREAM *astream) |
ACL_API int | acl_aio_get_accept_max (ACL_ASTREAM *astream) |
ACL_API void | acl_aio_set_accept_max (ACL_ASTREAM *astream, int accept_max) |
ACL_API void | acl_aio_add_read_hook (ACL_ASTREAM *astream, ACL_AIO_READ_FN callback, void *ctx) |
ACL_API void | acl_aio_add_write_hook (ACL_ASTREAM *astream, ACL_AIO_WRITE_FN callback, void *ctx) |
ACL_API void | acl_aio_add_close_hook (ACL_ASTREAM *astream, ACL_AIO_CLOSE_FN callback, void *ctx) |
ACL_API void | acl_aio_add_timeo_hook (ACL_ASTREAM *astream, ACL_AIO_TIMEO_FN callback, void *ctx) |
ACL_API void | acl_aio_add_connect_hook (ACL_ASTREAM *astream, ACL_AIO_CONNECT_FN callback, void *ctx) |
ACL_API void | acl_aio_del_read_hook (ACL_ASTREAM *astream, ACL_AIO_READ_FN callback, void *ctx) |
ACL_API void | acl_aio_del_write_hook (ACL_ASTREAM *astream, ACL_AIO_WRITE_FN callback, void *ctx) |
ACL_API void | acl_aio_del_close_hook (ACL_ASTREAM *astream, ACL_AIO_CLOSE_FN callback, void *ctx) |
ACL_API void | acl_aio_del_timeo_hook (ACL_ASTREAM *astream, ACL_AIO_TIMEO_FN callback, void *ctx) |
ACL_API void | acl_aio_del_connect_hook (ACL_ASTREAM *astream, ACL_AIO_CONNECT_FN callback, void *ctx) |
ACL_API void | acl_aio_clean_read_hooks (ACL_ASTREAM *astream) |
ACL_API void | acl_aio_clean_write_hooks (ACL_ASTREAM *astream) |
ACL_API void | acl_aio_clean_close_hooks (ACL_ASTREAM *astream) |
ACL_API void | acl_aio_clean_timeo_hooks (ACL_ASTREAM *astream) |
ACL_API void | acl_aio_clean_connect_hooks (ACL_ASTREAM *astream) |
ACL_API void | acl_aio_clean_hooks (ACL_ASTREAM *astream) |
ACL_API void | acl_aio_ctl (ACL_ASTREAM *astream, int name,...) |
ACL_API ACL_VSTREAM * | acl_aio_vstream (ACL_ASTREAM *astream) |
ACL_API void | acl_aio_gets (ACL_ASTREAM *astream) |
ACL_API void | acl_aio_gets_nonl (ACL_ASTREAM *astream) |
ACL_API void | acl_aio_read (ACL_ASTREAM *astream) |
ACL_API void | acl_aio_readn (ACL_ASTREAM *astream, int count) |
ACL_API ACL_VSTRING * | acl_aio_gets_peek (ACL_ASTREAM *astream) |
ACL_API ACL_VSTRING * | acl_aio_gets_nonl_peek (ACL_ASTREAM *astream) |
ACL_API ACL_VSTRING * | acl_aio_read_peek (ACL_ASTREAM *astream, int *count) |
ACL_API ACL_VSTRING * | acl_aio_readn_peek (ACL_ASTREAM *astream, int *count) |
ACL_API void | acl_aio_enable_read (ACL_ASTREAM *astream, ACL_AIO_NOTIFY_FN can_read_fn, void *context) |
ACL_API int | acl_aio_can_read (ACL_ASTREAM *astream) |
ACL_API void | acl_aio_disable_read (ACL_ASTREAM *astream) |
ACL_API int | acl_aio_isrset (ACL_ASTREAM *astream) |
ACL_API void | acl_aio_stream_set_line_length (ACL_ASTREAM *astream, int len) |
ACL_API int | acl_aio_stream_get_line_length (ACL_ASTREAM *astream) |
ACL_API void | acl_aio_stream_set_keep_read (ACL_ASTREAM *astream, int onoff) |
ACL_API int | acl_aio_stream_get_keep_read (ACL_ASTREAM *astream) |
ACL_API void | acl_aio_writen (ACL_ASTREAM *astream, const char *data, int dlen) |
ACL_API void | acl_aio_writev (ACL_ASTREAM *astream, const struct iovec *vector, int count) |
ACL_API void | acl_aio_vfprintf (ACL_ASTREAM *astream, const char *fmt, va_list ap) |
ACL_API void | ACL_PRINTF (2, 3) acl_aio_fprintf(ACL_ASTREAM *astream |
ACL_API void const char ACL_API void | acl_aio_enable_write (ACL_ASTREAM *astream, ACL_AIO_NOTIFY_FN can_write_fn, void *context) |
ACL_API void | acl_aio_disable_write (ACL_ASTREAM *astream) |
ACL_API int | acl_aio_iswset (ACL_ASTREAM *astream) |
ACL_API void | acl_aio_accept (ACL_ASTREAM *astream) |
ACL_API void | acl_aio_listen (ACL_ASTREAM *astream) |
ACL_API ACL_ASTREAM * | acl_aio_connect (ACL_AIO *aio, const char *addr, int timeout) |
ACL_API int | acl_aio_connect_addr (ACL_AIO *aio, const char *addr, int timeout, ACL_AIO_CONNECT_ADDR_FN callback, void *context) |
ACL_API void | acl_aio_disable_readwrite (ACL_ASTREAM *astream) |
ACL_API int | acl_aio_isset (ACL_ASTREAM *astream) |
ACL_API int | acl_aio_refer_value (ACL_ASTREAM *astream) |
ACL_API void | acl_aio_refer (ACL_ASTREAM *astream) |
ACL_API void | acl_aio_unrefer (ACL_ASTREAM *astream) |
ACL_API acl_int64 | acl_aio_request_timer (ACL_AIO *aio, ACL_EVENT_NOTIFY_TIME timer_fn, void *context, acl_int64 idle_limit, int keep) |
ACL_API acl_int64 | acl_aio_cancel_timer (ACL_AIO *aio, ACL_EVENT_NOTIFY_TIME timer_fn, void *context) |
ACL_API void | acl_aio_keep_timer (ACL_AIO *aio, ACL_EVENT_NOTIFY_TIME timer_fn, void *context, int onoff) |
ACL_API int | acl_aio_timer_ifkeep (ACL_AIO *aio, ACL_EVENT_NOTIFY_TIME timer_fn, void *context) |
变量 | |
ACL_API void const char * | fmt |
#define ACL_AIO_SET_CTX | ( | stream_ptr, | |
_ctx_ | |||
) |
#define ACL_AIO_SET_TIMEOUT | ( | stream_ptr, | |
_timeo_ | |||
) |
typedef int(* ACL_AIO_ACCEPT_FN) (ACL_ASTREAM *cstream, void *context) |
typedef int(* ACL_AIO_CLOSE_FN) (ACL_ASTREAM *astream, void *context) |
typedef int(* ACL_AIO_CONNECT_ADDR_FN) (const ACL_ASTREAM_CTX *ctx) |
异步连接远程服务器时的回调函数定义,该类型由 acl_aio_connect_addr() 使用
ctx | {ACL_ASTREAM_CTX*} 回调函数的参数,可以由 acl_astream_get_xxx 获得该对象中包含的对象指针 |
typedef int(* ACL_AIO_CONNECT_FN) (ACL_ASTREAM *cstream, void *context) |
typedef int(* ACL_AIO_LISTEN_FN) (ACL_ASTREAM *sstream, void *context) |
typedef int(* ACL_AIO_NOTIFY_FN) (ACL_ASTREAM *astream, void *context) |
typedef int(* ACL_AIO_READ_FN) (ACL_ASTREAM *astream, void *context, char *data, int dlen) |
typedef int(* ACL_AIO_TIMEO_FN) (ACL_ASTREAM *astream, void *context) |
typedef int(* ACL_AIO_WRITE_FN) (ACL_ASTREAM *astream, void *context) |
typedef struct ACL_ASTREAM ACL_ASTREAM |
typedef struct ACL_ASTREAM_CTX ACL_ASTREAM_CTX |
ACL_API void acl_aio_accept | ( | ACL_ASTREAM * | astream | ) |
异步接收一个客户端连接流, 并将该客户端流回传给用户
astream | {ACL_ASTREAM*} 处于监听状态的流 |
ACL_API void acl_aio_add_close_hook | ( | ACL_ASTREAM * | astream, |
ACL_AIO_CLOSE_FN | callback, | ||
void * | ctx | ||
) |
添加附加关闭回调函数
astream | {ACL_ASTREAM*} 异步流,不能为空 |
callback | {ACL_AIO_READ_FN} 回调函数,不能为空 |
ctx | {void*} callback 回调函数的回调参数,可以为空 |
ACL_API void acl_aio_add_connect_hook | ( | ACL_ASTREAM * | astream, |
ACL_AIO_CONNECT_FN | callback, | ||
void * | ctx | ||
) |
添加附加连接成功回调函数
astream | {ACL_ASTREAM*} 异步流,不能为空 |
callback | {ACL_AIO_READ_FN} 回调函数,不能为空 |
ctx | {void*} callback 回调函数的回调参数,可以为空 |
ACL_API void acl_aio_add_read_hook | ( | ACL_ASTREAM * | astream, |
ACL_AIO_READ_FN | callback, | ||
void * | ctx | ||
) |
添加附加读回调函数
astream | {ACL_ASTREAM*} 异步流,不能为空 |
callback | {ACL_AIO_READ_FN} 回调函数,不能为空 |
ctx | {void*} callback 回调函数的回调参数,可以为空 |
ACL_API void acl_aio_add_timeo_hook | ( | ACL_ASTREAM * | astream, |
ACL_AIO_TIMEO_FN | callback, | ||
void * | ctx | ||
) |
添加附加超时回调函数
astream | {ACL_ASTREAM*} 异步流,不能为空 |
callback | {ACL_AIO_READ_FN} 回调函数,不能为空 |
ctx | {void*} callback 回调函数的回调参数,可以为空 |
ACL_API void acl_aio_add_write_hook | ( | ACL_ASTREAM * | astream, |
ACL_AIO_WRITE_FN | callback, | ||
void * | ctx | ||
) |
添加附加写回调函数
astream | {ACL_ASTREAM*} 异步流,不能为空 |
callback | {ACL_AIO_READ_FN} 回调函数,不能为空 |
ctx | {void*} callback 回调函数的回调参数,可以为空 |
ACL_API int acl_aio_can_read | ( | ACL_ASTREAM * | astream | ) |
检测异步流有多少数据可读
astream | {ACL_ASTREM*} 异步流对象 |
0 表示有数据可读
ACL_API ACL_VSTREAM* acl_aio_cancel | ( | ACL_ASTREAM * | astream | ) |
取消异步IO过程,该功能主要是为了将异步IO流转换为同步IO流而写
astream | {ACL_ASTREAM*} 异步IO流 |
ACL_API acl_int64 acl_aio_cancel_timer | ( | ACL_AIO * | aio, |
ACL_EVENT_NOTIFY_TIME | timer_fn, | ||
void * | context | ||
) |
取消某个定时器任务, 该函数仅是 acl_event_cancel_timer 的简单封装.
aio | {ACL_AIO*} 异步通信引擎句柄 |
timer_fn | {ACL_EVENT_NOTIFY_TIME} 定时器任务回调函数. |
context | {void*} timer_fn 的参数之一. |
ACL_API void acl_aio_check | ( | ACL_AIO * | aio | ) |
主动检查 ACL_AIO 引擎中待关闭的异步流是否应该关闭,调用此函数后,一些需要 延迟关闭的异步流会被主动关闭
aio | {ACL_AIO*} 异步框架引擎句柄 |
ACL_API void acl_aio_clean_close_hooks | ( | ACL_ASTREAM * | astream | ) |
清除所有的附加关闭回调函数
astream | {ACL_ASTREAM*} 异步流,不能为空 |
ACL_API void acl_aio_clean_connect_hooks | ( | ACL_ASTREAM * | astream | ) |
清除所有的附加连接成功回调函数
astream | {ACL_ASTREAM*} 异步流,不能为空 |
ACL_API void acl_aio_clean_hooks | ( | ACL_ASTREAM * | astream | ) |
清除所有的附加回调函数
astream | {ACL_ASTREAM*} 异步流,不能为空 |
ACL_API void acl_aio_clean_read_hooks | ( | ACL_ASTREAM * | astream | ) |
清除所有的附加读回调函数
astream | {ACL_ASTREAM*} 异步流,不能为空 |
ACL_API void acl_aio_clean_timeo_hooks | ( | ACL_ASTREAM * | astream | ) |
清除所有的附加超时回调函数
astream | {ACL_ASTREAM*} 异步流,不能为空 |
ACL_API void acl_aio_clean_write_hooks | ( | ACL_ASTREAM * | astream | ) |
清除所有的附加写回调函数
astream | {ACL_ASTREAM*} 异步流,不能为空 |
ACL_API void acl_aio_clear_dns | ( | ACL_AIO * | aio | ) |
将 aio 句柄中绑定的 DNS 地址清理掉
aio | {ACL_AIO*} |
ACL_API ACL_ASTREAM* acl_aio_connect | ( | ACL_AIO * | aio, |
const char * | addr, | ||
int | timeout | ||
) |
异步连接一个远程服务器, 当连接流出错、超时或连接成功时将触发事件通知过程.
aio | {ACL_AIO*} 异步框架引擎句柄 |
addr | {const char*} 远程服务器地址, 格式: ip:port, 如: 192.168.0.1:80 |
timeout | {int} 连接超时的时间值,单位为秒 |
ACL_API int acl_aio_connect_addr | ( | ACL_AIO * | aio, |
const char * | addr, | ||
int | timeout, | ||
ACL_AIO_CONNECT_ADDR_FN | callback, | ||
void * | context | ||
) |
异步连接一个远程服务器,给定的地址可以是域名,以区别于 acl_aio_connect 函数, 使用本函数的首要条件是必须通过 acl_aio_set_dns 设置的域名服务器的地址
aio | {ACL_AIO*} 异步框架引擎句柄 |
addr | {const char*} 服务器地址,格式:domain:port,如:www.sina.com:80 |
timeout | {int} 连接超时的时间值,单位为秒 |
callback | {ACL_AIO_CONNECT_ADDR_FN} |
context | {void*} 传递给 callback 回调函数的参数 |
ACL_API ACL_AIO* acl_aio_create | ( | int | event_mode | ) |
创建一个异步通信的异步框架实例句柄, 可以指定是否采用 epoll/devpoll
event_mode | {int} 事件监听方式: ACL_EVENT_SELECT, ACL_EVENT_POLL , ACL_EVENT_KERNEL, ACL_EVENT_WMSG |
ACL_API ACL_AIO* acl_aio_create2 | ( | int | event_mode, |
unsigned int | nMsg | ||
) |
创建异步框架实例句柄, 可以指定是否采用 epoll/devpoll/windows message
event_mode | {int} 事件监听方式: ACL_EVENT_SELECT, ACL_EVENT_POLL , ACL_EVENT_KERNEL, ACL_EVENT_WMSG |
nMsg | {unsigned int} 当与 _WIN32 界面的消息整合时,即 event_mode 设为 ACL_EVENT_WMSG 时该值才有效,其表示与异步句柄绑定的消息值 |
根据事件引擎句柄创建异步对象句柄
event | {ACL_EVENT *} |
ACL_API void acl_aio_ctl | ( | ACL_ASTREAM * | astream, |
int | name, | ||
... | |||
) |
设置异步流的属性
astream | {ACL_ASTREAM*} 异步流对象 |
name | {int} 第一个控制参数 |
... | 变参列表,格式为:ACL_AIO_CTL_XXX, xxx, 最后一个控制参数 为 ACL_AIO_CTL_END |
ACL_API void acl_aio_del_close_hook | ( | ACL_ASTREAM * | astream, |
ACL_AIO_CLOSE_FN | callback, | ||
void * | ctx | ||
) |
删除附加关闭回调函数
astream | {ACL_ASTREAM*} 异步流,不能为空 |
callback | {ACL_AIO_READ_FN} 回调函数,不能为空 |
ctx | {void*} callback 回调函数的回调参数,可以为空 |
ACL_API void acl_aio_del_connect_hook | ( | ACL_ASTREAM * | astream, |
ACL_AIO_CONNECT_FN | callback, | ||
void * | ctx | ||
) |
删除附加连接成功回调函数
astream | {ACL_ASTREAM*} 异步流,不能为空 |
callback | {ACL_AIO_READ_FN} 回调函数,不能为空 |
ctx | {void*} callback 回调函数的回调参数,可以为空 |
ACL_API void acl_aio_del_dns | ( | ACL_AIO * | aio, |
const char * | dns_list | ||
) |
删除 DNS 服务器地址列表
aio | {ACL_AIO*} |
dns_list | {const char*} DNS 服务器地址列表,格式:ip1:port,ip2:port... |
ACL_API void acl_aio_del_read_hook | ( | ACL_ASTREAM * | astream, |
ACL_AIO_READ_FN | callback, | ||
void * | ctx | ||
) |
删除附加读回调函数
astream | {ACL_ASTREAM*} 异步流,不能为空 |
callback | {ACL_AIO_READ_FN} 回调函数,不能为空 |
ctx | {void*} callback 回调函数的回调参数,可以为空 |
ACL_API void acl_aio_del_timeo_hook | ( | ACL_ASTREAM * | astream, |
ACL_AIO_TIMEO_FN | callback, | ||
void * | ctx | ||
) |
删除附加超时回调函数
astream | {ACL_ASTREAM*} 异步流,不能为空 |
callback | {ACL_AIO_READ_FN} 回调函数,不能为空 |
ctx | {void*} callback 回调函数的回调参数,可以为空 |
ACL_API void acl_aio_del_write_hook | ( | ACL_ASTREAM * | astream, |
ACL_AIO_WRITE_FN | callback, | ||
void * | ctx | ||
) |
删除附加写回调函数
astream | {ACL_ASTREAM*} 异步流,不能为空 |
callback | {ACL_AIO_READ_FN} 回调函数,不能为空 |
ctx | {void*} callback 回调函数的回调参数,可以为空 |
ACL_API void acl_aio_disable_read | ( | ACL_ASTREAM * | astream | ) |
停止对一个数据流进行IO读操作
astream | {ACL_ASTREAM*} 异步数据流 |
ACL_API void acl_aio_disable_readwrite | ( | ACL_ASTREAM * | astream | ) |
停止对一个数据流进行IO读写操作
astream | {ACL_ASTREAM*} 异步数据流 |
ACL_API void acl_aio_disable_write | ( | ACL_ASTREAM * | astream | ) |
停止对一个数据流进行IO写操作
astream | {ACL_ASTREAM*} 异步数据流 |
ACL_API void* acl_aio_dns | ( | ACL_AIO * | aio | ) |
获得本 aio 句柄所绑定的 DNS 查询对象
aio | {ACL_AIO*} |
ACL_API void acl_aio_enable_read | ( | ACL_ASTREAM * | astream, |
ACL_AIO_NOTIFY_FN | can_read_fn, | ||
void * | context | ||
) |
设置异步流为读监听状态,当该流可读时则调用用户的回调函数
astream | {ACL_ASTREM*} 异步流对象 |
can_read_fn | {ACL_AIO_NOTIFY_FN} 用户回调函数 |
context | {void*} can_read_fn 的参数之一 |
ACL_API void const char ACL_API void acl_aio_enable_write | ( | ACL_ASTREAM * | astream, |
ACL_AIO_NOTIFY_FN | can_write_fn, | ||
void * | context | ||
) |
设置异步流为写监听状态,当该流可写时则调用用户的回调函数
astream | {ACL_ASTREM*} 异步流对象 |
can_write_fn | {ACL_AIO_NOTIFY_FN} 用户回调函数 |
context | {void*} can_write_fn 的参数之一 |
获得事件引擎的句柄
aio | {ACL_AIO*} 异步框架引擎句柄 |
ACL_API int acl_aio_event_mode | ( | ACL_AIO * | aio | ) |
获得事件所采用的模式
aio | {ACL_AIO*} 异步框架引擎句柄 |
ACL_API void acl_aio_free | ( | ACL_AIO * | aio | ) |
释放一个异步通信异步框架实例句柄,同时会释放掉非空的 aio->event 对象
aio | {ACL_AIO*} 异步框架引擎句柄 |
ACL_API void acl_aio_free2 | ( | ACL_AIO * | aio, |
int | keep | ||
) |
释放一个异步通信异步框架实例句柄
keep | {int} 是否同时释放掉 aio 所绑定的 event 事件句柄 |
aio | {ACL_AIO*} 异步框架引擎句柄 |
ACL_API int acl_aio_get_accept_max | ( | ACL_ASTREAM * | astream | ) |
获得监听描述符每次接收客户端连接的最大个数
astream | {ACL_ASTREAM *} 监听描述符流 |
ACL_API void* acl_aio_get_ctx | ( | ACL_ASTREAM * | stream | ) |
获得异步流的参数
stream | {ACL_ASTREAM*} 异步IO流 |
ACL_API int acl_aio_get_delay_sec | ( | ACL_AIO * | aio | ) |
获得当前异步引擎循环时的等待时间的秒部分
aio | {ACL_AIO*} 异步框架引擎句柄 |
ACL_API int acl_aio_get_delay_usec | ( | ACL_AIO * | aio | ) |
获得当前异步引擎循环时的等待时间的微秒部分
aio | {ACL_AIO*} 异步框架引擎句柄 |
ACL_API int acl_aio_get_keep_read | ( | ACL_AIO * | aio | ) |
异步IO框架是否是采用持续读模式
aio | {ACL_AIO*} 异步框架引擎句柄 |
ACL_API void acl_aio_gets | ( | ACL_ASTREAM * | astream | ) |
异步从流中读取一行数据, 当成功读取一行数据、出错、读超时时将回调用户的 注册函数: notify_fn
astream | {ACL_ASTREAM*} 受监控的流, 当该流有完整的一行数据、出错 或读超时时将回调用户的注册函数. 注: 读操作发生在异步框架内. 当通过 acl_aio_stream_set_line_length 设置了行最大长度限制,则当接收的 数据行过大时,为避免缓冲区溢出,该函数的处理过程将会在缓冲区达到该长度 限制时被触发,直接将数据交由使用者注册的回调过程 |
ACL_API void acl_aio_gets_nonl | ( | ACL_ASTREAM * | astream | ) |
异步从流中读取一行数据, 当成功读取一行数据、出错、读超时时将回调用户的 注册函数: notify_fn, 与 acl_aio_gets 功能类似, 但唯一的区别是返回的数据 data 中不包含 "\r\n" 或 "\n", 当读到一个空行时, 则 dlen == 0.
astream | {ACL_ASTREAM*} 受监控的流, 当该流有完整的一行数据、出错 或读超时时将回调用户的注册函数. 注: 读操作发生在异步框架内. 数据行过大时,为避免缓冲区溢出,该函数的处理过程将会在缓冲区达到该长度 限制时被触发,直接将数据交由使用者注册的回调过程 |
ACL_API ACL_VSTRING* acl_aio_gets_nonl_peek | ( | ACL_ASTREAM * | astream | ) |
尝试性读取一行数据(不包含
或 \r
)
astream | {ACL_ASTREM*} 异步流对象 |
ACL_API ACL_VSTRING* acl_aio_gets_peek | ( | ACL_ASTREAM * | astream | ) |
尝试性读取一行数据
astream | {ACL_ASTREM*} 异步流对象 |
ACL_API ACL_AIO* acl_aio_handle | ( | ACL_ASTREAM * | stream | ) |
从异步流中获得异步框架引擎句柄
stream | {ACL_ASTREAM*} 异步IO流 |
ACL_API void acl_aio_iocp_close | ( | ACL_ASTREAM * | astream | ) |
异步IO完成后关闭流,否则进行异步关闭动作,即需要等读写都完成时才关闭流
astream | {ACL_ASTREAM*} 异步数据流 |
ACL_API int acl_aio_isrset | ( | ACL_ASTREAM * | astream | ) |
判断流是否在异步事件的读监听集合中
astream | {ACL_ASTREAM*} 异步数据流 |
ACL_API int acl_aio_isset | ( | ACL_ASTREAM * | astream | ) |
判断流是否在异步事件的读或写监听集合中
astream | {ACL_ASTREAM*} 异步数据流 |
ACL_API int acl_aio_iswset | ( | ACL_ASTREAM * | astream | ) |
判断流是否在异步事件的写监听集合中
astream | {ACL_ASTREAM*} 异步数据流 |
ACL_API void acl_aio_keep_timer | ( | ACL_AIO * | aio, |
ACL_EVENT_NOTIFY_TIME | timer_fn, | ||
void * | context, | ||
int | onoff | ||
) |
设置是否需要循环启用通过 acl_aio_request_timer 设置的定时器任务
aio | {ACL_AIO*} 异步通信引擎句柄 |
timer_fn | {ACL_EVENT_NOTIFY_TIME} 定时器任务回调函数. |
context | {void*} timer_fn 的参数之一. |
onoff | {int} 是否重复定时器任务 |
ACL_API int acl_aio_last_nready | ( | ACL_AIO * | aio | ) |
获得本次事件循环被触发的事件次数
aio | {ACL_AIO*} 异步框架引擎句柄 |
ACL_API void acl_aio_listen | ( | ACL_ASTREAM * | astream | ) |
异步监听, 当监听流上出错、超时或有新连接到达时将触发监听事件通知过程, 当有 新连接时用户需在自己的注册函数里 accept() 该新连接.
astream | {ACL_ASTREAM*} 处于监听状态的流 |
ACL_API void acl_aio_loop | ( | ACL_AIO * | aio | ) |
异步IO消息循环(仅在单线程模式下调用)
aio | {ACL_AIO*} 异步框架引擎句柄 |
ACL_API ACL_ASTREAM* acl_aio_open | ( | ACL_AIO * | aio, |
ACL_VSTREAM * | stream | ||
) |
打开一个异步通信流的句柄
aio | {ACL_AIO*} 异步框架引擎句柄 |
stream | {ACL_VSTREAM*} 受监控的流, 当该流有完整的一行数据、出错 或读超时时将回调用户的注册函数. |
ACL_API void acl_aio_read | ( | ACL_ASTREAM * | astream | ) |
异步从流中读取数据, 读取的数据格式及长度没有特殊要求.
astream | {ACL_ASTREAM*} 处于读监控的流. 当该流出错、超时或已经读取了一定 长度的数据时将触发事件通知过程 注: 读操作发生在异步框架内. |
ACL_API ACL_VSTRING* acl_aio_read_peek | ( | ACL_ASTREAM * | astream, |
int * | count | ||
) |
尝试性从异步流中读取数据,如果有数据则返回没有则返回空
astream | {ACL_ASTREM*} 异步流对象 |
count | {int*} 函数返回后将存放本次读到的数据长度,返回值永远 >= 0 |
ACL_API void acl_aio_readn | ( | ACL_ASTREAM * | astream, |
int | count | ||
) |
异步从流中读取要求长度的数据, 当流出错、超时或读到了所要求的数据长度时将 触发事件通知过程
astream | {ACL_ASTREAM*} 处于读监控的流. 当该流出错、超时或已经读取了所 要求长度的数据时将触发事件通知过程 |
count | {int} 所要求的数据的长度, 必须大于 0. 注: 读操作发生在异步框架内. |
ACL_API ACL_VSTRING* acl_aio_readn_peek | ( | ACL_ASTREAM * | astream, |
int * | count | ||
) |
尝试性从异步流中读给定长度的数据,如果读到的数据满足要求则返回缓冲区
astream | {ACL_ASTREM*} 异步流对象 |
count | {int*} 要求读到的数据长度,函数返回后将存放本次读到的字节数, 存放的值永远 >= 0 |
ACL_API void acl_aio_refer | ( | ACL_ASTREAM * | astream | ) |
将异步流的引用计数值加1
astream | {ACL_ASTREAM*} 异步数据流 |
ACL_API int acl_aio_refer_value | ( | ACL_ASTREAM * | astream | ) |
获得当前异步流的引用计数值
astream | {ACL_ASTREAM*} 异步数据流 |
ACL_API acl_int64 acl_aio_request_timer | ( | ACL_AIO * | aio, |
ACL_EVENT_NOTIFY_TIME | timer_fn, | ||
void * | context, | ||
acl_int64 | idle_limit, | ||
int | keep | ||
) |
添加一个定时器任务, 该函数仅是 acl_event_request_timer 的简单封装
aio | {ACL_AIO*} 异步通信引擎句柄 |
timer_fn | {ACL_EVENT_NOTIFY_TIME} 定时器任务回调函数. |
context | {void*} timer_fn 的参数之一. |
idle_limit | {acl_int64} 启动定时器函数的时间,单位为微秒. |
keep | {int} 是否重复定时器任务 |
ACL_API void acl_aio_set_accept_max | ( | ACL_ASTREAM * | astream, |
int | accept_max | ||
) |
设置监听描述符每次接收客户端连接的最大个数
astream | {ACL_ASTREAM *} 监听描述符流 |
accept_max | {int} 监听描述符在每次接收过程中可以循环接收的最大连接 个数,此值最小为1 |
ACL_API void acl_aio_set_accept_nloop | ( | ACL_ASTREAM * | astream, |
int | nloop | ||
) |
设置监听异步流每次接收客户端连接时循环接收个数
astream | {ACL_ASTREAM*} 监听流 |
nloop | {int} |
ACL_API void acl_aio_set_check_inter | ( | ACL_AIO * | aio, |
int | check_inter | ||
) |
设置事件循环过程中定时检查所有描述字状态的时间间隔,内部缺省值为 100 ms
aio | {ACL_AIO*} 异步框架引擎句柄 |
check_inter | {int} 定时查检时间间隔 (毫秒级) |
ACL_API void acl_aio_set_ctx | ( | ACL_ASTREAM * | stream, |
void * | ctx | ||
) |
设置异步流的参数
stream | {ACL_ASTREAM*} 异步IO流 |
ctx | {void*} 参数 |
ACL_API void acl_aio_set_delay_sec | ( | ACL_AIO * | aio, |
int | delay_sec | ||
) |
设置异步引擎循环的等待时间中的秒级部分
aio | {ACL_AIO*} 异步框架引擎句柄 |
delay_sec | {int} 设置用 select/poll/epoll/kqueue/devpoll 时的秒级等待时间 |
ACL_API void acl_aio_set_delay_usec | ( | ACL_AIO * | aio, |
int | delay_usec | ||
) |
设置异步引擎循环的等待时间中的微秒级部分
aio | {ACL_AIO*} 异步框架引擎句柄 |
delay_usec | {int} 设置用 select/poll/epoll/kqueue/devpoll 时的微秒级等待时间 |
ACL_API int acl_aio_set_dns | ( | ACL_AIO * | aio, |
const char * | dns_list, | ||
int | timeout | ||
) |
设置 DNS 服务器地址列表,只有设置了 DNS 服务器地址,内部才会支持域名解析并 异步连接服务器地址
aio | {ACL_AIO*} |
dns_list | {const char*} DNS 服务器地址列表,格式:ip1:port,ip2:port... |
timeout | {int} 域名解析超时时间(秒) |
ACL_API void acl_aio_set_keep_read | ( | ACL_AIO * | aio, |
int | onoff | ||
) |
设置异步IO框架的持续读模式
aio | {ACL_AIO*} 异步框架引擎句柄 |
onoff | {int} 0: 关闭持续读功能; != 0: 打开持续读功能 |
ACL_API void acl_aio_set_rbuf_size | ( | ACL_AIO * | aio, |
int | rbuf_size | ||
) |
设置异步流的读缓存区大小
aio | {ACL_AIO*} 异步框架引擎句柄 |
rbuf_size | {int} 读缓冲区大小 |
ACL_API int acl_aio_stream_get_keep_read | ( | ACL_ASTREAM * | astream | ) |
获得异步流是否是设置了连续读标记
ACL_API int acl_aio_stream_get_line_length | ( | ACL_ASTREAM * | astream | ) |
获得所设置的流按行读数据时的最大长度限制
astream | {ACL_ASTREAM*} 异步数据流 |
ACL_API void acl_aio_stream_set_keep_read | ( | ACL_ASTREAM * | astream, |
int | onoff | ||
) |
单独设置异步流的连续读标记,缺省情况下自动继承 ACL_AIO 中的 keep_read 标记(其默认情况下是连续读)
astream | {ACL_ASTREAM*} 异步数据流 |
onoff | {int} 0 表示关闭连续读功能,非0表示打开连续读功能 |
ACL_API void acl_aio_stream_set_line_length | ( | ACL_ASTREAM * | astream, |
int | len | ||
) |
设置读一行数据时每行数据的最大长度限制,这样的目的主要是为了防止对方发送的 一行数据过长,造成本地接收缓冲区内存溢出
astream | {ACL_ASTREAM*} 异步数据流 |
len | {int} 当该值 > 0 时将会限制按行读的数据长度 |
ACL_API int acl_aio_timer_ifkeep | ( | ACL_AIO * | aio, |
ACL_EVENT_NOTIFY_TIME | timer_fn, | ||
void * | context | ||
) |
判断所设置的定时器都处于重复使用状态
aio | {ACL_AIO*} 异步通信引擎句柄 |
timer_fn | {ACL_EVENT_NOTIFY_TIME} 定时器任务回调函数. |
context | {void*} timer_fn 的参数之一. |
ACL_API void acl_aio_unrefer | ( | ACL_ASTREAM * | astream | ) |
将异步流的引用计数值减1
astream | {ACL_ASTREAM*} 异步数据流 |
ACL_API void acl_aio_vfprintf | ( | ACL_ASTREAM * | astream, |
const char * | fmt, | ||
va_list | ap | ||
) |
以格式方式异步向流中写数据, 当流出错、写超时或写成功时将触发事件通知过程
astream | {ACL_ASTREAM*} 处于写监控的流 |
fmt | {const char*} 格式字符串 |
ap | {va_list} 格式字符串的参数列表 |
ACL_API ACL_VSTREAM* acl_aio_vstream | ( | ACL_ASTREAM * | astream | ) |
ACL_API void acl_aio_writen | ( | ACL_ASTREAM * | astream, |
const char * | data, | ||
int | dlen | ||
) |
异步向流中写数据, 当流出错、写超时或写成功时将触发事件通知过程
astream | {ACL_ASTREAM*} 处于写监控的流. |
data | {const char*} 所写数据的内存开始指针位置 |
dlen | {int} data 中数据长度 |
ACL_API void acl_aio_writev | ( | ACL_ASTREAM * | astream, |
const struct iovec * | vector, | ||
int | count | ||
) |
异步向流中写数据, 当流出错、写超时或写成功时将触发事件通知过程,类似系统的 writev
astream | {ACL_ASTREAM*} 处于写监控的流. |
vector | {const struct iovec*} 数据集合数组 |
count | {int} vector 数组的长度 |
ACL_API ACL_ASTREAM* acl_astream_get_conn | ( | const ACL_ASTREAM_CTX * | ctx | ) |
ACL_API void* acl_astream_get_ctx | ( | const ACL_ASTREAM_CTX * | ctx | ) |
ACL_API const ACL_SOCKADDR* acl_astream_get_ns_addr | ( | const ACL_ASTREAM_CTX * | ctx | ) |
ACL_API const ACL_SOCKADDR* acl_astream_get_serv_addr | ( | const ACL_ASTREAM_CTX * | ctx | ) |
ACL_API int acl_astream_get_status | ( | const ACL_ASTREAM_CTX * | ctx | ) |
ACL_API ACL_VSTRING * ACL_PRINTF | ( | 2 | , |
3 | |||
) |
以格式方式异步向流中写数据, 当流出错、写超时或写成功时将触发事件通知过程
astream | {ACL_ASTREAM*} 处于写监控的流 |
fmt | {const char*} 格式字符串 |
... | 变参参数表 |
带格式的流输出, 类似于 fprintf()
fp | {ACL_VSTREAM*} 数据流 |
fmt | {const char*} 数据格式 |
... | 变参序列 |
以附加方式向缓冲区按格式方式添加数据
vp | {ACL_VSTRING*} |
format | {const char*} 格式化字符串 |
... | 变参序列 |
按规定格式向头部添加数据
vp | {ACL_VSTRING*} |
format | {const char*} |
... | 变参序列 |
ACL_API int const char * fmt |