Answer the question
In order to leave comments, you need to log in
How to make a synchronous recording in the pipe?
Hello everyone, I am making a two-way channel of two pipes and during testing I noticed that when writing data on one side I get a breakdown of the message upon receipt. For example
fthose. printed turned into three lines.
OnRead2 f
ffffff
OnRead2 f
OnRead2 ffff
OnRead2 f
if(mkfifo(pipeForWriting, S_IFIFO|S_IRWXU|S_IRWXG|S_IRWXO) != 0)
{
if(errno==EEXIST)
return 0;
printf("create named pipe error = %d\n", errno); /* произошла ошибка */
return errno;
}
pipeForWritingDescriptor = open(pipeForWriting, O_SYNC|O_WRONLY);
Answer the question
In order to leave comments, you need to log in
Is it clear now. Your best bet is to switch to "messages" with your own structure.
In the header of the message, simply put its length, and already in the loop you read the body itself until the length is reached. Thus, you will not depend on buffers and other write asynchrony.
Actually with sockets the same story, and with the rest of the threads.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question