【python】rpyc

通过最简单的一个调用例子:

Server端

from rpyc import Service
from rpyc.utils.server import ThreadedServer
import time

class pc2Service(Service):
    def exposed_get_time(self):
        now_time = time.time()
        print now_time    
        return now_time

S=ThreadedServer(pc2Service, port=12345)
S.start()

Client端

import rpyc
import time
c=rpyc.connect('192.168.250.20',12345)
for i in range(5):
    time.sleep(1.5)
    print c.root.get_time()
c.close()

抓包

1、首先通过3次握手建立TCP连接

2、基于建立的TCP连接传输远程调用命令及数据

追踪整个TCP流,只能看到调用了哪些命令,看不到具体传输的数据

......QP.S.Q.
...&..RP.T...34688896.
pc2Service..__main__
......QQ.`.Q...34688896
......RQ.Q.	..
_rpyc_setattr....exposed_get_time...
on_connect.)called when the connection is established..
__format__..default object formatter..
on_disconnect.icalled when the connection had already terminated for cleanup
(must not perform any IO on the connection)...__subclasshook__....3Abstract classes can override this to customize issubclass().

This is invoked early on by abc.ABCMeta.__subclasscheck__().
It should return True, False or NotImplemented.  If it returns
NotImplemented, the normal algorithm is used.  Otherwise, it
overrides the normal algorithm (and the outcome is cached)...
_rpyc_getattr...
_rpyc_delattr...
__sizeof__.2__sizeof__() -> size of object in memory, in bytes
......QR.T.Q...34688896..get_time
...-..RR.T...30243976..instancemethod..__builtin__
......QS.W.Q...30243976..
......RS.Q.A..V...o
......QT._.Q...30243976
......RT.Q.
......QU.T.Q...34688896..get_time
...-..RU.T...30225512..instancemethod..__builtin__
......QV.W.Q...30225512..
......RV.Q.A..V.{S.
......QW._.Q...30225512
......RW.Q.
......QX.T.Q...34688896..get_time
...-..RX.T...30243976..instancemethod..__builtin__
......QY.W.Q...30243976..
......RY.Q.A..V....
......QZ._.Q...30243976
......RZ.Q.
......Q[.T.Q...34688896..get_time
...-..R[.T...30225512..instancemethod..__builtin__
......Q\.W.Q...30225512..
......R\.Q.A..V.<.1
......Q]._.Q...30225512
......R].Q.
......Q^.T.Q...34688896..get_time
...-..R^.T...30243976..instancemethod..__builtin__
......Q_.W.Q...30243976..
......R_.Q.A..V..Z.
......Q`._.Q...30243976
......R`.Q.
......Qa.R.Q.

3、通过4次握手关闭连接

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值