I came across a zeromq example code
subscriber = ctx.socket(zmq.XSUB)
subscriber.connect("tcp://localhost:6000")
publisher = ctx.socket(zmq.XPUB)
publisher.bind("tcp://*:6001")
The subscriber (client) is connecting to local host port 6000. But the publisher (the server) is binding to *:6001
What does this mean?
It means "all interfaces, port 6001" - a given computer can have more than one network interface (a trivial example would be that the average computer's LAN IP and it's localhost address are two different interfaces. The * means to accept connections from any of them.
.bind() at port 6000 while .connect() aims at port 6001?Simply put, these two peers will not meet at this attempt to setup a link to communicate.
While wildcard does work for all <localhost> interfaces, it does not for port#-s.
A .bind() side can open it's receiving policy to accept a connection from any interface "behind" the * wild card, but the port#-s must match.
No exceptions, no excuse.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With