Re: Calling a stack from unix

Scott Raney ((no email))
Sun, 5 Jun 94 21:57:27 MDT

> >> I'm setting up a stack that will run at the same time as a C program.
> >> I would like to be able to call stack functions from the C program or
> >> at a unix prompt and to be able to call functions in the C program
> >> from the stack. I'd be interested in any ways you know of doing
> >> this.
>
> >You could also use open process to do this, but you'd have to develop
> >a protocol such that if MetaCard could call a function foo by doing
> >something like: write "foo" & return to process "your C program"
> >
> >Your C program would have to read from its stdin and decide which
> >function to call based on the string it reads. The MetaCard engine
> >would have to do the same when it reads a string from the process.
> >The advantage of the process approach is that calls would be faster
> >than equivalent external calls, and that your C program doesn't have
> >to use the X way of handling events (which may make it easier for you
> >to write functions that have long execution times since you don't have
> >to return to MetaCard right away as is required for externals). The
> >downsides are that it would be harder to implement and that passing
> >arguments is more difficult since you have to parse them up yourself.
>
> Could you explain how I would do this in a little more depth?

I could, but if you don't recognize the situation you probably haven't
done much protocol work and this certainly isn't the way to learn
about it. The external method or the signal method that I suggested
in my reply would both be quicker ways to your goal, I think.

If you wanted to experiment with developing a protocol, the way to
proceed would be to do it using two C programs, since that way you can
see exactly what's happening on both ends more easily (MetaCard does a
lot of management of the processes behind the scenes which would make
it more difficult to figure out what's going on). As I recommended in
an earlier message to this list, a good reference for this type of
work is W. Richard Stevens' UNIX Network Programming (Prentice Hall
ISBN 0-13-949876-1). His Advanced Programming in the UNIX Environment
(0-201-56317-7) covers this area too, and even has a simple example
(section 14.4) of using an external process to add two numbers which
is the first step toward what you want to do.
Scott

> Thank You
>
> David Humphreys
> MPR Teltech Ltd.
> Burnaaby, BC

-- 
***********************************************************************
* Scott Raney  303-447-3936            Remember: the better you look, *
* raney@metacard.com                   the more you'll see -- Lidia   *
***********************************************************************