Function nng::forwarder[][src]

pub fn forwarder(s1: RawSocket, s2: RawSocket) -> Result<()>
Expand description

Forwards messages between two sockets.

This function is used to create forwarders, which can be used to create complex network topologies to provide for improved horizontal scalability, reliability, and isolation. The provided sockets must have protocols that are compatible with each other. For example, if s1 is a sub socket then s2 must be a pub socket, or if s1 is a bus socket then s2 must be a bus socket as well.

Note that some protocols have a maximum time-to-live to protect against forwarding loops and especially amplification loops. In these cases, the default limit (usually 8), ensures that messages will self-terminate when they have passed through too many forwarders, protecting the network from unlimited message amplification that can arise through misconfiguration. This is controlled by the MaxTtl option.

This function does not return unless one of the sockets encounters an error or is closed. For more information see the NNG documentation.

Errors

In addition to returning any error that the underlying sockets can encounter, this function also has the following error conditions:

  • Closed: At least one of the sockets is not open.
  • InvalidInput: Sockets are not compatible or both are invalid.
  • OutOfMemory: Insufficient memory available.