[zeromq-dev] Newbie Question: php-zmq and the "Divide and Conquer" Example - "Failed to bind the ZMQ: Address already in use"
Martin Sustrik
sustrik at 250bpm.com
Tue Jan 4 18:39:49 CET 2011
Pieter,
It's a POSIX error, thus an integer, namely ENODEV.
Martin
On 01/04/2011 06:35 PM, Pieter Hintjens wrote:
> 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
> <mailto:kermodebear at gmail.com>> wrote:
> > Hello,
> >
> > 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
> > 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 127.0.0.1 as it
> should
> > and I hit my local box without an issue. I'm perplexed here.
> >
> > So, I decided to try to use 127.0.0.1 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://127.0.0.1:5557
> <http://127.0.0.1:5557>' 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 work
> > without any issues, so I'm certain that the problem is me.
> >
> > Thank you very much,
> > KBear
>
>
>
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
More information about the zeromq-dev
mailing list