Using protocol buffers in socket(Python)
I’m tring to write an application with protocol buffers to send data on socket connecet.I encountered some problems , this is my summary:
###Pre preparation
#####1.download Google protocol buffers.
look at this https://developers.google.com/protocol-buffers/
#####2.Buliding Google protocol buffers(Python).
if you see ‘…no module name google.protobuf..’ do this in Terminal:
(sudo)pip install protobuf
#####3.To understanding struct
###Main body
####Client
struct.pack('LL',type,len(protobuf_data))
‘LL’ means two long types,more types looks here
###Server
first in server i def a funcation name socket_read_n
then .
enjoy it!
Reference:
http://stackoverflow.com/questions/2038083/how-to-use-python-and-googles-protocol-buffers-to-deserialize-data-sent-over-tc