asio的事件投递主要由aico完成,除了accept只需要一次投递,永久有效外,其他事件投递都是一次性的,每次投递后,回调处理完,根据返回的状态,来判断是否需要继续投递。
- /*! init the aico
- *
- * @param aicp the aicp
- *
- * @return the aico
- */
- tb_aico_ref_t tb_aico_init(tb_aicp_ref_t aicp);
- /*! open the sock aico
- *
- * @param aicp the aicp
- * @param sock the socket
- *
- * @return tb_true or tb_false
- */
- tb_bool_t tb_aico_open_sock(tb_aico_ref_t aico, tb_socket_ref_t sock);
- /*! open the sock aico from the socket type
- *
- * @param aicp the aicp
- * @param type the socket type
- *
- * @return tb_true or tb_false
- */
- tb_bool_t tb_aico_open_sock_from_type(tb_aico_ref_t aico, tb_size_t type);
- /*! open the file aico
- *
- * @param aicp the aicp
- * @param file the file
- *
- * @return tb_true or tb_false
- */
- tb_bool_t tb_aico_open_file(tb_aico_ref_t aico, tb_file_ref_t file);
- /*! open the file aico from path
- *
- * @param aicp the aicp
- * @param path the file path
- * @param mode the file mode
- *
- * @return tb_true or tb_false
- */
- tb_bool_t tb_aico_open_file_from_path(tb_aico_ref_t aico, tb_char_t const* path, tb_size_t mode);
- /*! open the task aico
- *
- * @param aicp the aicp
- * @param ltimer is the lower precision timer?
- *
- * @return tb_true or tb_false
- */
- tb_bool_t tb_aico_open_task(tb_aico_ref_t aico, tb_bool_t ltimer);
- /*! kill the aico
- *
- * @param aico the aico
- */
- tb_void_t tb_aico_kill(tb_aico_ref_t aico);
- /*! exit the aico
- *
- * @param aico the aico
- */
- tb_void_t tb_aico_exit(tb_aico_ref_t aico);
- /*! the aico aicp
- *
- * @param aico the aico
- *
- * @return the aico aicp
- */
- tb_aicp_ref_t tb_aico_aicp(tb_aico_ref_t aico);
- /*! the aico type
- *
- * @param aico the aico
- *
- * @return the aico type
- */
- tb_size_t tb_aico_type(tb_aico_ref_t aico);
- /*! get the socket if the aico is socket type
- *
- * @param aico the aico
- *
- * @return the socket
- */
- tb_socket_ref_t tb_aico_sock(tb_aico_ref_t aico);
- /*! get the file if the aico is file type
- *
- * @param aico the aico
- *
- * @return the file
- */
- tb_file_ref_t tb_aico_file(tb_aico_ref_t aico);
- /*! try to close it
- *
- * @param aico the aico
- *
- * @return tb_true or tb_false
- */
- tb_bool_t tb_aico_clos_try(tb_aico_ref_t aico);
- /*! the aico timeout
- *
- * @param aico the aico
- * @param type the timeout type
- *
- * @return the timeout
- */
- tb_long_t tb_aico_timeout(tb_aico_ref_t aico, tb_size_t type);
- /*! set the aico timeout
- *
- * @param aico the aico
- * @param type the timeout type
- * @param timeout the timeout
- */
- tb_void_t tb_aico_timeout_set(tb_aico_ref_t aico, tb_size_t type, tb_long_t timeout);
- /*! post the clos
- *
- * @param aicp the aicp
- * @param func the func
- * @param priv the func private data
- *
- * @return tb_true or tb_false
- */
- tb_bool_t tb_aico_clos(tb_aico_ref_t aico, tb_aico_func_t func, tb_cpointer_t priv);
- /*! post the acpt
- *
- * @param aico the aico
- * @param func the callback func
- * @param priv the callback data
- *
- * @return tb_true or tb_false
- */
- tb_bool_t tb_aico_acpt(tb_aico_ref_t aico, tb_aico_func_t func, tb_cpointer_t priv);
- /*! post the conn
- *
- * @param aico the aico
- * @param addr the addr
- * @param port the port
- * @param func the callback func
- * @param priv the callback data
- *
- * @return tb_true or tb_false
- */
- tb_bool_t tb_aico_conn(tb_aico_ref_t aico, tb_ipv4_t const* addr, tb_uint16_t port, tb_aico_func_t func, tb_cpointer_t priv);
- /*! post the recv for sock
- *
- * @param aico the aico
- * @param data the data
- * @param size the size
- * @param func the callback func
- * @param priv the callback data
- *
- * @return tb_true or tb_false
- */
- tb_bool_t tb_aico_recv(tb_aico_ref_t aico, tb_byte_t* data, tb_size_t size, tb_aico_func_t func, tb_cpointer_t priv);
- /*! post the send for sock
- *
- * @param aico the aico
- * @param data the data
- * @param size the size, send the left file data if size == 0
- * @param func the callback func
- * @param priv the callback data
- *
- * @return tb_true or tb_false
- */
- tb_bool_t tb_aico_send(tb_aico_ref_t aico, tb_byte_t const* data, tb_size_t size, tb_aico_func_t func, tb_cpointer_t priv);
- /*! post the urecv for sock
- *
- * @param aico the aico
- * @param addr the addr
- * @param port the port
- * @param data the data
- * @param size the size
- * @param func the callback func
- * @param priv the callback data
- *
- * @return tb_true or tb_false
- */
- tb_bool_t tb_aico_urecv(tb_aico_ref_t aico, tb_ipv4_t const* addr, tb_uint16_t port, tb_byte_t* data, tb_size_t size, tb_aico_func_t func, tb_cpointer_t priv);
- /*! post the usend for sock
- *
- * @param aico the aico
- * @param addr the addr
- * @param port the port
- * @param data the data
- * @param size the size, send the left file data if size == 0
- * @param func the callback func
- * @param priv the callback data
- *
- * @return tb_true or tb_false
- */
- tb_bool_t tb_aico_usend(tb_aico_ref_t aico, tb_ipv4_t const* addr, tb_uint16_t port, tb_byte_t const* data, tb_size_t size, tb_aico_func_t func, tb_cpointer_t priv);
- /*! post the recvv for sock
- *
- * @param aico the aico
- * @param list the list
- * @param size the size
- * @param func the callback func
- * @param priv the callback data
- *
- * @return tb_true or tb_false
- */
- tb_bool_t tb_aico_recvv(tb_aico_ref_t aico, tb_iovec_t const* list, tb_size_t size, tb_aico_func_t func, tb_cpointer_t priv);
- /*! post the sendv for sock
- *
- * @param aico the aico
- * @param list the list
- * @param size the size
- * @param func the callback func
- * @param priv the callback data
- *
- * @return tb_true or tb_false
- */
- tb_bool_t tb_aico_sendv(tb_aico_ref_t aico, tb_iovec_t const* list, tb_size_t size, tb_aico_func_t func, tb_cpointer_t priv);
- /*! post the urecvv for sock
- *
- * @param aico the aico
- * @param addr the addr
- * @param port the port
- * @param list the list
- * @param size the size
- * @param func the callback func
- * @param priv the callback data
- *
- * @return tb_true or tb_false
- */
- tb_bool_t tb_aico_urecvv(tb_aico_ref_t aico, tb_ipv4_t const* addr, tb_uint16_t port, tb_iovec_t const* list, tb_size_t size, tb_aico_func_t func, tb_cpointer_t priv);
- /*! post the usendv for sock
- *
- * @param aico the aico
- * @param addr the addr
- * @param port the port
- * @param list the list
- * @param size the size
- * @param func the callback func
- * @param priv the callback data
- *
- * @return tb_true or tb_false
- */
- tb_bool_t tb_aico_usendv(tb_aico_ref_t aico, tb_ipv4_t const* addr, tb_uint16_t port, tb_iovec_t const* list, tb_size_t size, tb_aico_func_t func, tb_cpointer_t priv);
- /*! post the sendfile for sock
- *
- * @param aico the aico
- * @param file the file handle
- * @param seek the seek
- * @param size the size, send the left data if size == 0
- * @param func the callback func
- * @param priv the callback data
- *
- * @return tb_true or tb_false
- */
- tb_bool_t tb_aico_sendf(tb_aico_ref_t aico, tb_file_ref_t file, tb_hize_t seek, tb_hize_t size, tb_aico_func_t func, tb_cpointer_t priv);
- /*! post the read for file
- *
- * @param aico the aico
- * @param seek the seek
- * @param data the data
- * @param size the size
- * @param func the callback func
- * @param priv the callback data
- *
- * @return tb_true or tb_false
- */
- tb_bool_t tb_aico_read(tb_aico_ref_t aico, tb_hize_t seek, tb_byte_t* data, tb_size_t size, tb_aico_func_t func, tb_cpointer_t priv);
- /*! post the writ for file
- *
- * @param aico the aico
- * @param seek the seek
- * @param data the data
- * @param size the size
- * @param func the callback func
- * @param priv the callback data
- *
- * @return tb_true or tb_false
- */
- tb_bool_t tb_aico_writ(tb_aico_ref_t aico, tb_hize_t seek, tb_byte_t const* data, tb_size_t size, tb_aico_func_t func, tb_cpointer_t priv);
- /*! post the readv for file
- *
- * @param aico the aico
- * @param seek the seek
- * @param list the list
- * @param size the size
- * @param func the callback func
- * @param priv the callback data
- *
- * @return tb_true or tb_false
- */
- tb_bool_t tb_aico_readv(tb_aico_ref_t aico, tb_hize_t seek, tb_iovec_t const* list, tb_size_t size, tb_aico_func_t func, tb_cpointer_t priv);
- /*! post the writv for file
- *
- * @param aico the aico
- * @param seek the seek
- * @param list the list
- * @param size the size
- * @param func the callback func
- * @param priv the callback data
- *
- * @return tb_true or tb_false
- */
- tb_bool_t tb_aico_writv(tb_aico_ref_t aico, tb_hize_t seek, tb_iovec_t const* list, tb_size_t size, tb_aico_func_t func, tb_cpointer_t priv);
- /*! post the fsync for file
- *
- * @param aico the aico
- * @param func the callback func
- * @param priv the callback data
- *
- * @return tb_true or tb_false
- */
- tb_bool_t tb_aico_fsync(tb_aico_ref_t aico, tb_aico_func_t func, tb_cpointer_t priv);
- /*! post the clos after the delay time
- *
- * @param aico the aico
- * @param delay the delay time, ms
- * @param func the callback func
- * @param priv the callback data
- *
- * @return tb_true or tb_false
- */
- tb_bool_t tb_aico_clos_after(tb_aico_ref_t aico, tb_size_t delay, tb_aico_func_t func, tb_cpointer_t priv);
- /*! post the acpt after the delay time
- *
- * @param aico the aico
- * @param delay the delay time, ms
- * @param func the callback func
- * @param priv the callback data
- *
- * @return tb_true or tb_false
- */
- tb_bool_t tb_aico_acpt_after(tb_aico_ref_t aico, tb_size_t delay, tb_aico_func_t func, tb_cpointer_t priv);
- /*! post the conn after the delay time
- *
- * @param aico the aico
- * @param delay the delay time, ms
- * @param addr the addr
- * @param port the port
- * @param func the callback func
- * @param priv the callback data
- *
- * @return tb_true or tb_false
- */
- tb_bool_t tb_aico_conn_after(tb_aico_ref_t aico, tb_size_t delay, tb_ipv4_t const* addr, tb_uint16_t port, tb_aico_func_t func, tb_cpointer_t priv);
- /*! post the recv for sock after the delay time
- *
- * @param aico the aico
- * @param delay the delay time, ms
- * @param data the data
- * @param size the size
- * @param func the callback func
- * @param priv the callback data
- *
- * @return tb_true or tb_false
- */
- tb_bool_t tb_aico_recv_after(tb_aico_ref_t aico, tb_size_t delay, tb_byte_t* data, tb_size_t size, tb_aico_func_t func, tb_cpointer_t priv);
- /*! post the send for sock after the delay time
- *
- * @param aico the aico
- * @param delay the delay time, ms
- * @param data the data
- * @param size the size, send the left file data if size == 0
- * @param func the callback func
- * @param priv the callback data
- *
- * @return tb_true or tb_false
- */
- tb_bool_t tb_aico_send_after(tb_aico_ref_t aico, tb_size_t delay, tb_byte_t const* data, tb_size_t size, tb_aico_func_t func, tb_cpointer_t priv);
- /*! post the urecv for sock after the delay time
- *
- * @param aico the aico
- * @param delay the delay time, ms
- * @param addr the addr
- * @param port the port
- * @param data the data
- * @param size the size
- * @param func the callback func
- * @param priv the callback data
- *
- * @return tb_true or tb_false
- */
- tb_bool_t tb_aico_urecv_after(tb_aico_ref_t aico, tb_size_t delay, tb_ipv4_t const* addr, tb_uint16_t port, tb_byte_t* data, tb_size_t size, tb_aico_func_t func, tb_cpointer_t priv);
- /*! post the usend for sock after the delay time
- *
- * @param aico the aico
- * @param delay the delay time, ms
- * @param addr the addr
- * @param port the port
- * @param data the data
- * @param size the size, send the left file data if size == 0
- * @param func the callback func
- * @param priv the callback data
- *
- * @return tb_true or tb_false
- */
- tb_bool_t tb_aico_usend_after(tb_aico_ref_t aico, tb_size_t delay, tb_ipv4_t const* addr, tb_uint16_t port, tb_byte_t const* data, tb_size_t size, tb_aico_func_t func, tb_cpointer_t priv);
- /*! post the recvv for sock after the delay time
- *
- * @param aico the aico
- * @param delay the delay time, ms
- * @param list the list
- * @param size the size
- * @param func the callback func
- * @param priv the callback data
- *
- * @return tb_true or tb_false
- */
- tb_bool_t tb_aico_recvv_after(tb_aico_ref_t aico, tb_size_t delay, tb_iovec_t const* list, tb_size_t size, tb_aico_func_t func, tb_cpointer_t priv);
- /*! post the sendv for sock after the delay time
- *
- * @param aico the aico
- * @param delay the delay time, ms
- * @param list the list
- * @param size the size
- * @param func the callback func
- * @param priv the callback data
- *
- * @return tb_true or tb_false
- */
- tb_bool_t tb_aico_sendv_after(tb_aico_ref_t aico, tb_size_t delay, tb_iovec_t const* list, tb_size_t size, tb_aico_func_t func, tb_cpointer_t priv);
- /*! post the urecvv for sock after the delay time
- *
- * @param aico the aico
- * @param delay the delay time, ms
- * @param addr the addr
- * @param port the port
- * @param list the list
- * @param size the size
- * @param func the callback func
- * @param priv the callback data
- *
- * @return tb_true or tb_false
- */
- tb_bool_t tb_aico_urecvv_after(tb_aico_ref_t aico, tb_size_t delay, tb_ipv4_t const* addr, tb_uint16_t port, tb_iovec_t const* list, tb_size_t size, tb_aico_func_t func, tb_cpointer_t priv);
- /*! post the usendv for sock after the delay time
- *
- * @param aico the aico
- * @param delay the delay time, ms
- * @param addr the addr
- * @param port the port
- * @param list the list
- * @param size the size
- * @param func the callback func
- * @param priv the callback data
- *
- * @return tb_true or tb_false
- */
- tb_bool_t tb_aico_usendv_after(tb_aico_ref_t aico, tb_size_t delay, tb_ipv4_t const* addr, tb_uint16_t port, tb_iovec_t const* list, tb_size_t size, tb_aico_func_t func, tb_cpointer_t priv);
- /*! post the sendfile for sock after the delay time
- *
- * @param aico the aico
- * @param delay the delay time, ms
- * @param file the file handle
- * @param seek the seek
- * @param size the size, send the left data if size == 0
- * @param func the callback func
- * @param priv the callback data
- *
- * @return tb_true or tb_false
- */
- tb_bool_t tb_aico_sendf_after(tb_aico_ref_t aico, tb_size_t delay, tb_file_ref_t file, tb_hize_t seek, tb_hize_t size, tb_aico_func_t func, tb_cpointer_t priv);
- /*! post the read for file after the delay time
- *
- * @param aico the aico
- * @param delay the delay time, ms
- * @param seek the seek
- * @param data the data
- * @param size the size
- * @param func the callback func
- * @param priv the callback data
- *
- * @return tb_true or tb_false
- */
- tb_bool_t tb_aico_read_after(tb_aico_ref_t aico, tb_size_t delay, tb_hize_t seek, tb_byte_t* data, tb_size_t size, tb_aico_func_t func, tb_cpointer_t priv);
- /*! post the writ for file after the delay time
- *
- * @param aico the aico
- * @param delay the delay time, ms
- * @param seek the seek
- * @param data the data
- * @param size the size
- * @param func the callback func
- * @param priv the callback data
- *
- * @return tb_true or tb_false
- */
- tb_bool_t tb_aico_writ_after(tb_aico_ref_t aico, tb_size_t delay, tb_hize_t seek, tb_byte_t const* data, tb_size_t size, tb_aico_func_t func, tb_cpointer_t priv);
- /*! post the readv for file after the delay time
- *
- * @param aico the aico
- * @param delay the delay time, ms
- * @param seek the seek
- * @param list the list
- * @param size the size
- * @param func the callback func
- * @param priv the callback data
- *
- * @return tb_true or tb_false
- */
- tb_bool_t tb_aico_readv_after(tb_aico_ref_t aico, tb_size_t delay, tb_hize_t seek, tb_iovec_t const* list, tb_size_t size, tb_aico_func_t func, tb_cpointer_t priv);
- /*! post the writv for file after the delay time
- *
- * @param aico the aico
- * @param delay the delay time, ms
- * @param seek the seek
- * @param list the list
- * @param size the size
- * @param func the callback func
- * @param priv the callback data
- *
- * @return tb_true or tb_false
- */
- tb_bool_t tb_aico_writv_after(tb_aico_ref_t aico, tb_size_t delay, tb_hize_t seek, tb_iovec_t const* list, tb_size_t size, tb_aico_func_t func, tb_cpointer_t priv);
- /*! post the fsync for file after the delay time
- *
- * @param aico the aico
- * @param delay the delay time, ms
- * @param func the callback func
- * @param priv the callback data
- *
- * @return tb_true or tb_false
- */
- tb_bool_t tb_aico_fsync_after(tb_aico_ref_t aico, tb_size_t delay, tb_aico_func_t func, tb_cpointer_t priv);
- /*! run aico task after timeout and will be auto-remove it after be expired
- *
- * only once, need continue to call it again if want to repeat task
- *
- * @param aico the aico
- * @param delay the delay time, ms
- * @param func the callback func
- * @param priv the callback data
- *
- * @return tb_true or tb_false
- */
- tb_bool_t tb_aico_task_run(tb_aico_ref_t aico, tb_size_t delay, tb_aico_func_t func, tb_cpointer_t priv);