Java & Google Protocol Buffers: I need an example of how to use Google Protocol Buffers with client-server communication
Looking for the best example you guys know of.
The examples on the site are with files. But the library should be able to w开发者_运维知识库ork over a Java.net.ServerSocket, at least I hope.
You can certainly write protocol buffers to an OutputStream
and read them from an InputStream
. The Protocol Buffers project itself hasn't specified an RPC protocol, but third parties have done so. Alternatively, if you're simply interested in transmitting a message, you should be able to wrap that message in any protocol which allows you to either specify a byte array and retrieve it at the other end, or which gives you a stream-based API.
If you need an example using a specific RPC technique listed in the third party add-ons page, I suggest you look at the home of that particular project.
精彩评论