Two-way pipes?

W

webmaster

Sorry if this sounds naive, but I need to know how to create a two-way
pipe between my Objective-C MacOSX program and another process, like
perl, for example. Is there a simple way to do this in C, or one in the
Apple Foundation kit for Objective-C?
 
V

Vladimir S. Oka

Sorry if this sounds naive, but I need to know how to create a
two-way pipe between my Objective-C MacOSX program and another
process, like perl, for example. Is there a simple way to do
this in C, or one in the Apple Foundation kit for Objective-C?

I believe that reading the stdin, processing (if needed), and
writing to stdout is how you go about it, until you encounter
EOF condition on stdin.

Why can't you just output to stdout (or appropriate equivalent)
in Objective-C, and capture stdin (or appropriate equivalent)
in Perl, or whatever? I don't really see the need for an
additional layer.

Cheers

Vladimir
 
T

Tom Harrington

Sorry if this sounds naive, but I need to know how to create a two-way
pipe between my Objective-C MacOSX program and another process, like
perl, for example. Is there a simple way to do this in C, or one in the
Apple Foundation kit for Objective-C?

Since you said "pipe", the obvious choice is Unix-style pipes. Start
with "man 2 pipe", but honestly you'll want a decent Unix programming
book before if you intend on using pipes in real code.

If you prefer an Apple/ObjC style approach, see NSPipe. Apple provides
a simple example of NSPipe at
<http://developer.apple.com/documentation/Cocoa/Conceptual/OperatingSyste
m/Tasks/pipes.html#//apple_ref/doc/uid/20000805-BAJEEBAB>.

Whether pipes are actually suitable for your needs depends on what
you're really trying to accomplish.
 
R

Randy Howard

(e-mail address removed) wrote
(in article
Sorry if this sounds naive, but I need to know how to create a two-way
pipe between my Objective-C MacOSX program and another process, like
perl, for example. Is there a simple way to do this in C, or one in the
Apple Foundation kit for Objective-C?

comp.lang.objective-c is right down the hall on your right.
 
K

Keith Thompson

Randy Howard said:
(e-mail address removed) wrote
(in article


comp.lang.objective-c is right down the hall on your right.

He posted to both comp.lang.c and comp.lang.objective-c.

To the OP: since standard C doesn't support pipes (they're an
extension), they're off-topic in comp.lang.c. Followups redirected.
(Apologies if they're also off-top in comp.lang.objective-c.)
 
K

Kenny McCormack

Keith Thompson said:
He posted to both comp.lang.c and comp.lang.objective-c.

Yes, but that is the way of clc. Frequently, over the years, I've seen
(newbies) people post something to about 20 groups, including clc, where
the thing was topical for, say 19 of those groups (but not, of course, in
clc, where nothing substantive is topical) and then either the first or
close to the first response will be from some dork in clc telling everybody
that it is not topical in clc - and, of course, sending that response to
all 20 groups.

So, you have the picture of people in these 19 other groups, where, as I've
said, the thing might have been entirely topical (this due, largely, to
their groups not having the Nazi-like standards that clc has) reading about
its non-topicality in some fringe group (i.e., this one). Must have been
a universally weird experience for them.

In summary, in case the point isn't clear, is that saying "Well, he posted
to a collection of groups, some topical, some not." is not a justification
for letting him off the hook in terms of his topicality w.r.t. clc.
 
K

Kenny McCormack

Kenny McCormack wrote


no, I simply missed the cross-posting, I didn't check the
headers.

While it may or may not apply directly to you personally, you cannot deny
the truth of the situation that I describe. I've seen it happen many times
over the years.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
474,173
Messages
2,570,937
Members
47,481
Latest member
ElviraDoug

Latest Threads

Top