Hi Zhao,
You don't send "messages" in rpyc. You can functions. Your client connects
to a server, like so
>>> import rpyc
>>> c = rpyc.classic.connect("localhost")
(Assuming you started a rpyc_classic on your localhost)
And then you can call remote functions/use remote objects, e.g.,
>>> c.modules.os.getpid()
1273
>>> c.modules.sys.platform
"linux2"
So far I've demonstrated the client invoking objects on the server. You can
also have the server invoke objects on the client, by passing a reference
to them.
For example:
>>> def double(x):
... return x*2
...
>>> c.builtin.map(square, c.builtin.range(10))
[0, 2, 4, 6, 8, 10, 12, 14, 16, 18]
Here we invoked the remote map() function on a remote list object
(c.builtin.range is the remote range() function), using a local function
(double),
yielding the expected results. You can also use asynchronous calls (
http://rpyc.readthedocs.org/en/latest/tutorial/tut5.html#tut5), to mimic
events
or concurrency, but that would be more advance. I suggest you start with
the first tutorial (http://rpyc.readthedocs.org/en/latest/tutorial.html).
Note that there's a second flavor of using rpyc, called services:
http://rpyc.readthedocs.org/en/latest/docs/services.html#services
Services allow you to define the APIs exposed by the two parties, and you
may find them useful in the future.
Hope this gets you going,
-tomer
-----------------------------------------------------------------
*Tomer Filiba*
tomerfiliba.com <http://www.facebook.com/tomerfiliba>
<http://il.linkedin.com/in/tomerfiliba>
On Mon, Sep 1, 2014 at 3:30 PM, Zhao Gao <[email protected]>
wrote:
> Hi, everyone.
>
> I am a newbie about Python and RPyC. Now I met a problem that I need to
> achieve inter-process communication between two processes. I tried to use
> Service mode RPYcC, and I can send message from server to client
> successfully. That is easy. The thing is how to send message from client to
> server?
>
> Please help me.
>
> Thank you very much.
>
>
> --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "rpyc" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>
--
---
You received this message because you are subscribed to the Google Groups
"rpyc" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.