Skip to content

io_service options

The following are the io_service options.

Name Description
YOPT_S_DEFER_EVENT_CB Set defer event callback
params: callback:defer_event_cb_t
remarks:
a. User can do custom packet resolve at network thread, such as decompress and crc check.
b. Return true, io_service will continue enque to event queue.
c. Return false, io_service will drop the event.
YOPT_S_DEFERRED_EVENT Set whether deferred dispatch event, default is: 1
params: deferred_event:int(1)
YOPT_S_RESOLV_FN Set custom resolve function, native C++ ONLY
params: func:resolv_fn_t*
YOPT_S_PRINT_FN Set custom print function native C++ ONLY
parmas: func:print_fn_t
remarks: you must ensure thread safe of it
YOPT_S_PRINT_FN2 Set custom print function with log level
parmas: func:print_fn2_t
you must ensure thread safe of it
YOPT_S_EVENT_CB Set event callback
params: func:event_cb_t*
YOPT_S_TCP_KEEPALIVE Set tcp keepalive in seconds, probes is tries.
params: idle:int(7200), interal:int(75), probes:int(10)
YOPT_S_NO_NEW_THREAD Don't start a new thread to run event loop.
params: value:int(0)
YOPT_S_SSL_CACERT Sets ssl verification cert, if empty, don't verify.
params: path:const char*
YOPT_S_CONNECT_TIMEOUT Set connect timeout in seconds.
params: connect_timeout:int(10)
YOPT_S_DNS_CACHE_TIMEOUT Set dns cache timeout in seconds.
params: dns_cache_timeout : int(600),
YOPT_S_DNS_QUERIES_TIMEOUT Set dns queries timeout in seconds, default is: 5000.
params: dns_queries_timeout : int(5000)
remark:
a. this option must be set before 'io_service::start'
b. only works when have c-ares
c. since v3.33.0 it's milliseconds, previous is seconds.
d. the timeout algorithm of c-ares is complicated, usually, by default, dns queries
will failed with timeout after more than 75 seconds.
e. for more detail, please see:
https://c-ares.haxx.se/ares_init_options.html
YOPT_S_DNS_QUERIES_TRIES Set dns queries tries when timeout reached, default is: 5.
params: dns_queries_tries : int(5)
remarks:
a. this option must be set before 'io_service::start'
b. relative option: YOPT_S_DNS_QUERIES_TIMEOUT
YOPT_S_DNS_DIRTY Set dns server dirty.
params: reserved : int(1)
remarks:
a. this option only works with c-ares enabled
b. you should set this option after your mobile network changed
YOPT_C_LFBFD_FN Sets channel length field based frame decode function.
params: index:int, func:decode_len_fn_t*
remark: native C++ ONLY
YOPT_C_LFBFD_PARAMS Sets channel length field based frame decode params.
params:
index:int,
max_frame_length:int(10MBytes),
length_field_offset:int(-1),
length_field_length:int(4),
length_adjustment:int(0),
YOPT_C_LFBFD_IBTS Sets channel length field based frame decode initial bytes to strip.
params:index:int,initial_bytes_to_strip:int(0)
YOPT_C_REMOTE_HOST Sets channel remote host.
params: index:int, ip:const char*
YOPT_C_REMOTE_PORT Sets channel remote port.
params: index:int, port:int
YOPT_C_REMOTE_ENDPOINT Sets channel remote endpoint.
params: index:int, ip:const char*, port:int
YOPT_C_LOCAL_HOST Sets local host for client channel only.
params: index:int, ip:const char*
YOPT_C_LOCAL_PORT Sets local port for client channel only.
params: index:int, port:int
YOPT_C_LOCAL_ENDPOINT Sets local endpoint for client channel only.
params: index:int, ip:const char*, port:int
YOPT_C_MOD_FLAGS Mods channl flags.
params: index:int, flagsToAdd:int, flagsToRemove:int
YOPT_C_ENABLE_MCAST Enable channel multicast mode.
params: index:int, multi_addr:const char*, loopback:int
YOPT_C_DISABLE_MCAST Disable channel multicast mode.
params: index:int
YOPT_C_KCP_CONV The kcp conv id, must equal in two endpoint from the same connection.
params: index:int, conv:int
YOPT_T_CONNECT Change 4-tuple association for io_transport_udp.
params: transport:transport_handle_t
remark: only works for udp client transport
YOPT_T_DISCONNECT Dissolve 4-tuple association for io_transport_udp.
params: transport:transport_handle_t
remark: only works for udp client transport
YOPT_B_SOCKOPT Sets io_base sockopt.
params: io_base*,level:int,optname:int,optval:int,optlen:int

See also

io_service Class