Ok Ali. But i'm pretty new to this whole socket thing. The guy am working with 
actually achieved the same thing as I want to on C#. The code is pretty much 
the same as what I have and he says he's receiving the messages. You said the 
send and recv methods are in block mode by default. How can I unblock it so 
that the messages come in. This task is pretty easy as I'm not doing any 
complex socket implementation. Can you go through my short code to see where I 
could have gone wrong? Thank you

 
Regards,
Olanrewaju Lawal
Web Developer / Programmer
+2348053568948



________________________________
From: Amr Ali <amr.ali...@gmail.com>
To: lanre lawal <lawillas4e...@yahoo.com>
Sent: Wednesday, October 12, 2011 1:09 AM
Subject: Re: [zeromq-dev] PHP Error on Ubuntu

This is not very helpful, the reasons for this to block endlessly are so many
it's hard for me to cover in one email, but I'll list few things to check ...

1) the PHP implementation of setSockOpt() does subscribe to an empty topic ("")
and not some random default topic.
2) the server actually is up and sending messages.
3) the server is using a compatible socket (PUB).
4) this is unlikely, but check and see if port 2060 is tcp wrapped and ACL is
configured, if you don't know what that is, don't worry about it.

According to the latest 0MQ implementation, the recv/send methods are in
blocking mode by default, which explains why you block indefinitely.

Also note that there are other socket options that allows you to timeout after a
certain period of time has elapsed, I'm not sure if this is available for 2.x
but it's available for 3.x. you can emulate the same effect by poll()ing on the
socket for a ZMQ_POLLIN event with a reasonable timeout.

I advise you to read on zguide and actually try to do things at the localhost
level first (both the client and the server side parts) to make sure everything
is working, then deploy your apps accordingly.

Regards,
Amr Ali

On 10/12/2011 01:52 AM, lanre lawal wrote:
> Ok So after taking your advice to use the PUB/SUB, here´s a revised version of
> my code. It doesn´t give me an error now but the page just keeps loading
> endlessly without any message displayed.
> 
> $context = new ZMQContext();
> echo "Collecting data from the MDT server\n";
> $subscriber = new ZMQSocket($context, ZMQ::SOCKET_SUB);
> $subscriber->connect("tcp://24.187.208.22:2060");
> $subscriber->setSockOpt(ZMQ::SOCKOPT_SUBSCRIBE);
> //while(true){
>     $string = $subscriber->recv();
>     echo $string;
> //}
>  
> Does it matter that i´m running this on my localhost?
> Regards,
> Olanrewaju Lawal
> Web Developer / Programmer
> +2348053568948
> 
> --------------------------------------------------------------------------------
> *From:* Amr Ali <amr.ali...@gmail.com>
> *To:* ZeroMQ development list <zeromq-dev@lists.zeromq.org>
> *Sent:* Wednesday, October 12, 2011 12:41 AM
> *Subject:* Re: [zeromq-dev] PHP Error on Ubuntu
> 
> It depends on what he wants to do, if he wants to have several sockets 
> receiving
> the same message, he then should use PUB/SUB, otherwise PUSH/PULL pattern 
> should
> work smoothly.
> 
> PUB/SUB should work in a setup that looks like this ...
> 
> [Publisher]
>     -
>     -
>     ------> [Subscriber]
>     -
>     ------> [Subscriber]
>     -
>     ------> [Subscriber]
> 
> In that setup *all* the subscribers receive the *same* message the publisher
> sends. Think RSS.
> 
> PUSH/PULL should work in a setup more similar to this ...
> 
> [Pusher]
>     .
>     .
>     ......> [Puller]
>     ......> [Puller]
>     ......> [Puller]
> 
> Where only *one* of the pullers will receive the message and other's won't, 
> this
> works best if you want an LRU functionality (think load-balancer).
> 
> On 10/12/2011 01:27 AM, Mikko Koppanen wrote:
>> On Wed, Oct 12, 2011 at 12:24 AM, lanre lawal <lawillas4e...@yahoo.com
> <mailto:lawillas4e...@yahoo.com>> wrote:
>>> Hello Ali,
>>>      Well for what iḿ trying to achieve I really don´t need to send any
>>> messages, All i need to do is receive the messages so am thinking maybe the
>>> send() part would have to go off. The documentation site is currently down
>>> so I can´t access the documentation. Is there a soft copy of the
>>> documentation that I can get from somewhere else. Maybe you can help me from
>>> your experience. I´ll explain what I actually want to achieve.
>>>
>>> There´s a dedicated IP address that is currently receiving messages from
>>> some devices, now I want to connect to this address and receive these
>>> messages. Thats just what I want to do. Can you give me steps on how to do
>>> this or better still send me a soft copy of the documentation.
>>
>> Hi,
>>
>> if you want to just receive message then REQ/REP is the wrong pattern
>> for you. You should use PUB/SUB for this scenario. The
>> http://zguide.zeromq.org/ contains examples in PHP as well.
>>
>> -- mikko
>> _______________________________________________
>> zeromq-dev mailing list
>> zeromq-dev@lists.zeromq.org <mailto:zeromq-dev@lists.zeromq.org>
>> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
> 
> 
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev@lists.zeromq.org <mailto:zeromq-dev@lists.zeromq.org>
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
> 
> 
_______________________________________________
zeromq-dev mailing list
zeromq-dev@lists.zeromq.org
http://lists.zeromq.org/mailman/listinfo/zeromq-dev

Reply via email to