Is there design patterns I can use to implement an RPC (client-server) in C++
I'm working on a personal project which is an RPC (client-server) in C++. The RPC will communicate over TCP/IP or HTTP. The spec of the RPC is here :
http://groups.google.com/group/json-rpc/web/json-rpc-2-0
I'm wondering if there is an existing design pattern (or a combination of pattern) that could help me to produce a clean and flexible design. I will appreciate to have code examples, UML diagrams, o开发者_如何学Pythonr articles.
Thanks.
You are probably going to need a Proxy on the client to represent and make callable locally any server-side methods that you will be calling.
Under the covers, Abstract Factory could be useful to encapsulate provision of a concrete network connection that is selected using a configured or requested protocol (TCP, HTTP).
I would go for Observer.
Details and diagrams.
It's not clear if you asking in regards to high level design (observer patterns, JSON/XML processing techniques, etc.), low level design (sockets, HTTP client/server handling, etc.), or both.
If interested in lower level aspects including scalability, it might be worthwhile to study the design and motivations behind ASIO: http://think-async.com/Asio/asio-1.3.1/doc/asio/overview.html .
精彩评论