[zeromq-dev] Newbie Question: php-zmq and the "Divide and Conquer" Example - "Failed to bind the ZMQ: Address already in use"

Kermode Bear kermodebear at gmail.com
Tue Jan 4 18:20:15 CET 2011


I have just started working with ZeroMQ and thought that it would be a great
fit for a personal project of mine that is being written in PHP. In order to
learn the ins and outs, I thought it would be a good idea to start by
translating the C examples into PHP.

I am currently working on the "Divide and Conquer" example given in the
ZeroMQ guide. It is my understanding that:
1. The Ventilator is started;
2. One or more Workers are started;
3. The Sink is started;
4. The Ventilator is then told to send messages to the Workers.

When porting the code directly, the Worker is to
bind('tcp://localhost:5557'). However, this fails on my system with the
ZMQSocketException: Failed to bind the ZMQ: No such device

I'm going to guess that this is a problem with my local system, but when I
ping localhost, or use ftp/ssh/etc., it resolves to as it should
and I hit my local box without an issue. I'm perplexed here.

So, I decided to try to use directly instead of localhost. When I
do this, I receive the following error message:
ZMQSocketException: Failed to bind the ZMQ: Address already in use in
/home/kermode/zmq/example/worker.php on line 4

I am currently running Ubuntu Server 8.04 (2.6.24-19-server), ZeroMQ 2.0.10,
and the master trunk of php-zmq.

Below are two simplified versions of the code that are capable of producing
both errors. Change 'tcp://localhost:5557' to 'tcp://' in
worker.php for the second error.

$context = new ZMQContext();
$sender  = new ZMQSocket($context, ZMQ::SOCKET_PUSH);
$sender->send('This is a test message.');

$context = new ZMQContext();
$recv    = new ZMQSocket($context, ZMQ::SOCKET_PULL);

Start the ventilator process, then start the worker process to see things

Where am I breaking things? The examples from the php-zmq site seem to work
without any issues, so I'm certain that the problem is me.

Thank you very much,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20110104/5d9bb63c/attachment.htm>

More information about the zeromq-dev mailing list