uNetworking / uSockets

Miniscule cross-platform eventing, networking & crypto for async applications
Apache License 2.0
1.29k stars 268 forks source link

Better support for 3rd party polls #66

Closed ivan2kh closed 5 years ago

ivan2kh commented 5 years ago

Hi, Alex. I would like to propose a better support for 3rd party polls. The idea is to make another net libraries work together with uSockets in the same loop. I have investigated the public API

  1. I see there is no way to provide a callback function for the us_poll_t. The essential structure (us_internal_callback) is internal. Also poll_types enum from us_poll_init is declared in internal header.
  2. The most promising poll type is POLL_TYPE_CALLBACK since it just calls user’s callback. But user’s callback misses events argument.

Finally I suggest to implement a custom version of us_poll_init: void us_poll_init_custom(struct us_poll_t p, LIBUS_SOCKET_DESCRIPTOR fd, void (cb)(struct us_poll_t *p, int events));

What would you say? May I provide a pull request for the proposal?

ghost commented 5 years ago

You could also go for using libuv - uSockets can run on libuv and libuv has support for what you want

ivan2kh commented 5 years ago

Thank you for your help. libuv will suffice.

ghost commented 5 years ago

Yes I think that is the better solution for now - libuv is very popular and works well with usockets