-1

I have client that send messages serialized by protobuf to the server via 
linux fifo. I use ifstream and ofstream in my code for I / O operations.

If I write like this:

//clientClient::request() {
  std::ofstream pipeOut;
  pipeOut.open(outputPipeName);
  msg.SerializeToOstream(&pipeOut);
  pipeOut.close();
  ...}
//serverServer::process_requests() {
  std::ifstream pipeIn;

  while(isRunning) {
    pipeIn.open(inputPipeName);
    msg.ParseFromIstream(&pipeIn);
    pipeIn.close();
    ...
  }
}

everything works perfectly. But I don't want to constantly open and close 
the streams. Instead, I want to write something like this:

//clientclass Client {
  std::ofstream pipeOut;};
Client::Client() {
  pipeOut.open(outputPipeName);}
Client::~Client() {
  pipeOut.close();}

Client::request() {
  msg.SerializeToOstream(&pipeOut);
  ...}
//serverServer::process_requests() {
  std::ifstream pipeIn;
  pipeIn.open(inputPipeName);  

  while(isRunning) {
    msg.ParseFromIstream(&pipeIn);
    ...
  }

  pipeIn.close();}

but with this code server blockes inside ParseFromIstream function and the 
execution of the program goes no further. Can anybody please tell me how to 
write this correctly?

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.

Reply via email to