Integrating Request-Response and Stream Setups in swarm for Efficient Data Transfer?

I’m working on a project where I need to enable a single node in my Swarm network to dial a specific peer ID and efficiently send data to another node on the network. However, I’ve encountered an issue where I can’t use libp2p stream because the libp2p_stream::Behaviour doesn’t implement Network behaviour.

Given this constraint, what are the best practices or alternative approaches to achieve both request-response and stream setups within libp2p? I want to ensure that the communication remains efficient and secure while allowing seamless data transfer between nodes.

Any insights or code examples demonstrating how to set up this type of direct peer-to-peer communication in libp2p would be greatly appreciated. Thank you!

Hello @vinay10949!
Did you check the File Sharing example in Rust? I think it is very relevant to your case.

That being said, I’m not sure about the size limit of a request-response flow, or that if it allows streaming etc. In any case, with the way that it is shown in example I guess you can implement chunking on your side, so that a file is sent in multiple requests concurrently, and collected on the other side.