Skip to content

io_event Class

The event produced by io_service thread.


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:


Gets kind of event.

int kind() const;

Return value

Return the kind value, can be follow values

  • YEK_PACKET: Packet event
  • YEK_CONNECT_RESPONSE: Connect response event
  • YEK_CONNECTION_LOST: Connection lost event


Gets the status of event.

int status() const;

Return Value

  • 0: No error
  • NZ: error occured, user only needs print the error status code.


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.


Get timestamp in microseconds of event.

highp_time_t timestamp() const;

Return value

Return the timestamp in macroseconds.


Gets transport unique id.

unsigned int transport_id() const;

Return Value

Return a unique id range in 32 bit uint.


Sets or Gets transport userdata.

template<typename _Uty>
_Uty io_event::transport_udata();

template<typename _Uty>
void io_event::transport_udata(_Uty uservalue);


User should manage the gc of userdata, such as:

  • Store userdata when receive connect success event.
  • Cleanup the userdata when receive connection lost.

See also

io_service Class

io_channel Class