examples: use SocketListener::accept_future instead of SocketService #137
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
SocketService
wrapsSocketListener
to accept connections asynchronously and pass them along in the callback.This is unnecessary in an async world as we have
SocketListener::accept_future
which allows us to accept connections asynchronously in a loop.In #114 where I add this gio server example, there's a comment about how it would be nice to implement gtk-rs/gtk-rs-core#1064 so we can have a less awkward way to accept the connections in a loop like you would expect from other async libraries.
But having tried to do that, it seems like the problem is that
SocketService
is the wrong abstraction for async and we already have enough to do this. You might still prefer anincoming()
to match async-std and the stdlib listener, but given I realised we can accept in a loop in async, I wanted to update the example so there's a nice example to reference meanwhile.