io_event Class¶
The event produced by io_service thread.
Syntax¶
namespace yasio { namespace inet { class io_event; } }
Public Methods¶
Name | Description |
---|---|
io_event::kind | Gets kind of event. |
io_event::status | Gets status of event. |
io_event::packet | Gets packet of event. |
io_event::timestamp | Gets timestamp of event. |
io_event::transport | Gets transport of event. |
io_event::transport_id | Gets transport id of event. |
io_event::transport_udata | Gets/Sets transport user data. |
.. _kind:
io_event::kind¶
Gets kind of event.
int kind() const;
Return value¶
Return the kind value, can be follow values
YEK_PACKET
: Packet eventYEK_CONNECT_RESPONSE
: Connect response eventYEK_CONNECTION_LOST
: Connection lost event
io_event::status¶
Gets the status of event.
int status() const;
Return Value¶
- 0: No error
- NZ: error occured, user only needs print the error status code.
io_event::packet¶
Gets packet of event.
std::vector<char>& packet()
Return value¶
Return the mutable reference to packet of event, user can use std::move to move it.
io_event::timestamp¶
Get timestamp in microseconds of event.
highp_time_t timestamp() const;
Return value¶
Return the timestamp in macroseconds.
io_event::transport_id¶
Gets transport unique id.
unsigned int transport_id() const;
Return Value¶
Return a unique id range in 32 bit uint.
io_event::transport_udata¶
Sets or Gets transport userdata.
template<typename _Uty>
_Uty io_event::transport_udata();
template<typename _Uty>
void io_event::transport_udata(_Uty uservalue);
Remark¶
User should manage the gc of userdata, such as:
- Store userdata when receive connect success event.
- Cleanup the userdata when receive connection lost.