Should I save stream for future messages or dial every time?

Hi.

In the examples both nodes are on the same file and 2nd node is added to addressbook (the addressbook is never used again) and a single message is send to the node via the stream after a dialProtcol call.

So how should I make it to send several messages to the nodes?

  1. keep the stream of each node from a single dialProtocol call or
  2. Call dialProtocol for each message I need to send?

Thanks.

1 Like

It’s sad to see this hasn’t been answered. Could depend on library, protocol, and use case. Though I hate it when ppl ask questions about what I’m doing instead of telling me what I should be doing, it’s about all I can do on this one. I just don’t know what you should be doing… I’ve chosen to use Rust and I think I’ll adopt http’s keep alive semantics… I wonder if the server can disconnect the client just as easily as the client can disconnect, are there half-open pipes?

Hi Thanks for answering.

I finally decided not to keep streams and dial every time I need to send a message.
Probably there will be many disconnections so dialing every time seems to be the logical thing to do.

Cheers.