Daily Archives: December 24, 2021

json-rpc整理(JSON remote procedure call)

json rpc 類似xml rpc,透過HTTP的方式進行資料交換來達成remote procedure call,最大的差別在data serialization改成JSON,另外json rpc的規範大約在2005-2010年左右,在底層的傳輸協定也不要求使用HTTP,可以是TCP/IP stream。 spec可參考 1.0 https://www.jsonrpc.org/specification_v1 2.0 https://www.jsonrpc.org/specification 概念上跟xml rpc相同,但是將client server的角色模糊了,採用對等peer的概念,當然如果以功能來看,我們可以將make function call那端看成client,function execution那端看成client,只是在json rpc中的連線概念是採用對等,任何一端可能是client,也可能是server,為了清楚的對比xml rpc文章中的範例,以下我將xml rpc中is_even改成在json rpc裡實現,用Node.js當server,python當client 輸入100 回傳結果如下 使用起來簡單直覺,python 可以再利用語言本身的proxy機制,讓呼叫起來比較簡潔 以下整理json rpc 1.0 spec 其中提到 To invoke a remote method, a request … Continue reading

Posted in Network | Leave a comment