0mq only works with messages.  If you want to messages to indicate
functions to be called or arguments to be passed, you have to do that work
yourself.  0mq doesn't know what a Python function is, or how to serialize
a list of arguments.  Thankfully it is relatively straightforward in Python
and in many other languages to accomplish this and has already been done.
 Check out ZeroRPC, it's a Remote Procedure Call library that works over
zeromq:

http://zerorpc.dotcloud.com/

zerorpc isn't your only option, there are many rpc libraries for Python,
most of which don't use 0mq.

http://stackoverflow.com/questions/1879971/what-is-the-current-choice-for-doing-rpc-in-python

-Michel


On Mon, Apr 28, 2014 at 9:15 AM, Jess Updegrove <jessu...@gmail.com> wrote:

> Hello Community!
>
> I'm a new programmer and I'm trying to build a server that has a bunch of
> different functions. I want the architecture to be server-client, in which
> a client can connect to the server, send it a list of parameters and the
> function it wants the result from, and get a reply. However, I just cannot
> seem to figure out how to do this in ZMQ and I'm looking for guidance. I'm
> using Python (2.7) and the pyzmq library with the latest version of ZMQ.
> I've read the Guide multiple times and looked through a bunch of examples.
> Essentially, I want the convo between the client and server to go something
> like this:
>
> C: Server, give me the current temperature in Seattle, Washington using
> the function get_weather()
> S: Accessing get_weather() with argument "Seattle" [goes to it's function
> and gets the result]
> S: Here's the result!
> C: Server, change the temperature (in a database) for Seattle from 50 to
> 70.
> S: Accessing change_value() with key temperature.Seattle.
> S: Value updated!
>
>  However, I can only find examples that allow me to send a message but not
> specify a list of arguments. I also just can't seem to figure out the best
> way to send a message from the client and have the server pick it apart and
> figure out which function to call without using a ton of if statements
> checking the message content. Is ZMQ suitable for what I'm doing? Am I
> approaching it incorrectly? Also note that I already built a similar
> architecture like this is WAMPV2 using RPC calls and that's essentially
> what I'm trying to replicate. I'm new with the terminology used by ZMQ
> (sockets, threads, etc.) so it's very likely I'm just confused about how it
> all works. Any help would be appreciated!
>
> Thanks
>
>
> _______________________________________________
> zeromq-dev mailing list
> 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