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

Bill Six billsix at gmail.com
Mon Dec 17 21:10:21 UTC 2012


Since you are relatively new to Linux, write two simple programs in C which
use pipes to communicate (the first program is the producer, the second is
the consumer).   You'll need fork, exec, and probably dup2.

Once done, porting the consumer to Mono is straightforward. (Assuming you
know C and C# well enough).

In a day or 2, when I have access to a computer instead of just a tablet, I
will send a solution to you.

Bill

On Dec 17, 2012 12:05 PM, "mickeyf" <mickey at thesweetoasis.com> wrote:
>
> 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.
> _______________________________________________
> Mono-list maillist  -  Mono-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ximian.com/pipermail/mono-list/attachments/20121217/90c15712/attachment.html>


More information about the Mono-list mailing list