Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

examples: use SocketListener::accept_future instead of SocketService #137

Merged
merged 1 commit into from
Jul 8, 2024

Conversation

carlosmn
Copy link
Contributor

@carlosmn carlosmn commented Jul 7, 2024

SocketService wraps SocketListener 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 an incoming() 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.

`SocketService` wraps `SocketListener` 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.
@sdroege sdroege merged commit 6030fe3 into sdroege:main Jul 8, 2024
8 checks passed
@sdroege
Copy link
Owner

sdroege commented Jul 8, 2024

Thanks! This looks indeed nicer

@carlosmn carlosmn deleted the cmn/gio-server-with-stream branch July 8, 2024 07:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants