Skip to content

Socket closed #4979

Answered by thomaseizinger
cyrus937 asked this question in Q&A
Dec 5, 2023 · 1 comments · 10 replies
Discussion options

You must be logged in to vote

Thanks for sharing the code. I'd suggest to reconsider the design a bit that you've chosen.

For one, you are directly interacting with stdio from within the Rust code. It would be better to employ message passing via a channel. See https://github.com/libp2p/rust-libp2p/blob/master/examples/file-sharing/src/network.rs for some inspiration.

Secondly, it is really important that you continuously, without interruption call Swarm::next() and handle each event with minimal latency. The Swarm is essentially a giant Future and will not make progress if you stop polling it. If you follow the above pattern of an eventloop with message passing, that is solved for you.

In regards to your FFI design, …

Replies: 1 comment 10 replies

Comment options

You must be logged in to vote
10 replies
@thomaseizinger
Comment options

@thomaseizinger
Comment options

@cyrus937
Comment options

@thomaseizinger
Comment options

Answer selected by cyrus937
@cyrus937
Comment options

@thomaseizinger
Comment options

@cyrus937
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants