[Mono-list] Questions on Mono.Unix.Pipes

mickeyf mickey at thesweetoasis.com
Mon Dec 17 17:05:07 UTC 2012


I have some questions about Mono.Unix.Pipes.

I have been using this with some success, but I am relatively new to Linux,
and the mono documentation that I have found is missing or incomplete. The
Linux manual pages docs on pipes are clearly referring to a different animal
than this.

Specifically, I have been creating a pipe in a Mono app, passing the handle
of the write end to a shared library. The shared library writes data to the
pipe, which is read by the read end of the pipe on the mono app. This works,
although the case in which all the data is not gotten in a single read
operation gets messy.

It appears that I can read a pipe as mypipes.readend.Read(buffer_to_read_to,
read_position, bytes_to_read).

I understand that I can't actually fseek using read_position, but it seems
that if I do not read the entire bytes_to_read, I can then continue to
adjust read_position to read the remaining data.

1) Is this correct usage, or am I missing something here?

2) Since I can't find documentation specific to this, it's not clear what
the return values from Read will be when I can't actually read anything.
Does -1 indicate error, or simply "no data available"? What about 0?

3) Can I set the write end to disable O_NONBLOCK, and does this guarantee
that both the write and the read are atomic and that all bytes will in fact
be read in a single read on the read end of the pipe? (Assuming no SIG???)
If so, how do I do this?

If there is actual detailed documentation on Mono.Unix.Pipes, directing me
to that would be great.

Or, since what I really want to do is guarantee that a entire (privately
defined) data packet as written by my C library code is read by my mono app,
perhaps there is an entirely different, and better way to do this? Sockets?
Or...?

Thanks



--
View this message in context: http://mono.1490590.n4.nabble.com/Questions-on-Mono-Unix-Pipes-tp4657794.html
Sent from the Mono - General mailing list archive at Nabble.com.


More information about the Mono-list mailing list