mirror of
https://github.com/zeromq/libzmq.git
synced 2025-10-15 07:14:49 +02:00
Allow to set up a source address and port for outgoing tcp connections in zmq_connect()
Few examples: tcp:://192.168.0.4:55555;192.168.0.254:1234 tcp:://192.168.0.4:0;192.168.0.254:1234 tcp:://eth2:55555;192.168.0.254:1234
This commit is contained in:
@@ -261,6 +261,15 @@ int zmq::tcp_connecter_t::open ()
|
||||
if (options.tos != 0)
|
||||
set_ip_type_of_service (s, options.tos);
|
||||
|
||||
// Set a source address for conversations
|
||||
if (addr->resolved.tcp_addr->has_src_addr ()) {
|
||||
rc = ::bind (s, addr->resolved.tcp_addr->src_addr (), addr->resolved.tcp_addr->src_addrlen ());
|
||||
|
||||
if (rc == -1) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
// Connect to the remote peer.
|
||||
rc = ::connect (
|
||||
s, addr->resolved.tcp_addr->addr (),
|
||||
|
Reference in New Issue
Block a user