How can we hard code port number in client in zmq push pull socket

569 views Asked by At

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.

0

There are 0 answers