Python: sending request to protobuf server
Can anyone help me?
I have a .proto file.
How to send and print a request to a socket server from a client? How to answer the client?
protofile:
option optimize_for = SPEED;
option java_package = "org.epicsquad.protofile.proto";
package protofile.proto;
enum CommandTypeEnum {
COMMAND_one = 0;
COMMAND_two = 1;
COMMAND_three = 2;
}
enum ResultTypeEnum {
RESULT_ONE = 0;
RESULT_TWO = 1;
message Result {
required uint32 result_one = 1;
optional string result_two = 2;
}
message Request {
optional string req1 = 1;
optional string req2 = 2;
}
message Response {
required string resp1 = 1;
required string resp2 = 2;
}
Server:
import sys
sys.path.append('../../main')
import protobuf.socketrpc.server as server
server = server.SocketRpcServer(8090)
print 'Serving on port 8090'
server.run()
customer:
import sys sys.path.append('../../main') import protofile_pb2 from protobuf.socketrpc import RpcService import logging log = logging.getLogger(__name__) logging.basicConfig(level=logging.DEBUG) hostname = 'localhost' port = 8090 request = protofile_pb2.Request()
I have a HelloWorld example but have a send request via SERVICE. But there are no service messages in my .protofile. Thank!
+3
source to share