2

In case of connecting to zmq server, zmq client will pick random port number from local range. Usually in case of any tcp connection, we should be able to bind and connect the client to server. And hence, client can use a fixed port number (src port number).

How can we achieve this in zmq push pull socket case ? Any example please.

I was trying

sender.bind("tcp://eth0:50000");

receiver.bind("tcp://eth0:50001");

sender.connect("tcp://10.58.171.74:31055");

receiver.connect("tcp://10.58.171.74:31056");

but I could see, ports opened as below in client setup.

tcp        0      0 10.244.0.12:50000       0.0.0.0:*               LISTEN      1/./client

tcp        0      0 10.244.0.12:50001       0.0.0.0:*               LISTEN      1/./client

tcp        0      0 10.244.0.12:46438       10.58.171.74:31056      ESTABLISHED 1/./client

tcp        0      0 10.244.0.12:33520       10.58.171.74:31055      ESTABLISHED 1/./client

Instead my expectation was

10.244.0.12:50000       10.58.171.74:31056    ESTABLISHED 

10.244.0.12:50001       10.58.171.74:31056    ESTABLISHED 

Could you guys help me, to achieve this.

Nithin Sen
  • 51
  • 5
  • 1
    zmq sockets are not real (BSD) sockets but an abstraction of a message queue which provides similar (but note the same) semantics. There can actually be multiple underlyingTCP connections involved in a single zmq socket so binding to a specific source TCP ip:port makes no sense. As for what bind and connect actually mean - see [the documentation](https://zeromq.org/socket-api/). – Steffen Ullrich Sep 27 '20 at 13:03
  • Thank you Steffen.. Your comment was really helpful. – Nithin Sen Feb 23 '21 at 05:54

0 Answers0