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

Pieter Hintjens ph at imatix.com
Tue Jan 4 18:35:02 CET 2011

Is there any way to make the error message more useful? E.g. "bind failed
(use interface name or *): no such device"
On 4 Jan 2011 18:20, "Kermode Bear" <kermodebear at gmail.com> wrote:
> Hello,
> I have just started working with ZeroMQ and thought that it would be a
> fit for a personal project of mine that is being written in PHP. In order
> 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
> message:
> 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
> 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
> and the master trunk of php-zmq.
> Below are two simplified versions of the code that are capable of
> both errors. Change 'tcp://localhost:5557' to 'tcp://' in
> worker.php for the second error.
> ventilator.php:
> <?php
> $context = new ZMQContext();
> $sender = new ZMQSocket($context, ZMQ::SOCKET_PUSH);
> $sender->bind('tcp://*:5557');
> $sender->send('This is a test message.');
> ?>
> worker.php:
> <?php
> $context = new ZMQContext();
> $recv = new ZMQSocket($context, ZMQ::SOCKET_PULL);
> $recv->bind('tcp://localhost:5557');
> var_dump($recv->recv());
> ?>
> Start the ventilator process, then start the worker process to see things
> explode.
> Where am I breaking things? The examples from the php-zmq site seem to
> without any issues, so I'm certain that the problem is me.
> Thank you very much,
> KBear
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20110104/8406dbd4/attachment.htm>

More information about the zeromq-dev mailing list