Simple Resource Manager

Hi all,

I’m trying to write a simple Resorce Manager that
accepts a string from a client and returns another
string that simply says that the string has been received

Example:

A client Java program using standard I/O funcs opens the
RM and writes: “Hello!”

and resource manager should return to the client:
“Hello! has been received.”

Using the examples of RM’s in the manuals I managed to
write and read to/from a RM, but independently, i.e. I can write
Hello!, but if I perform a read(…) I got back an empty string.
If I do the read without the write I can get
“has been received.”

Thanks

Juan Carlos

juan carlos <jcd@dcs.st-and.ac.uk> wrote:

Hi all,

I’m trying to write a simple Resorce Manager that
accepts a string from a client and returns another
string that simply says that the string has been received

Example:

A client Java program using standard I/O funcs opens the
RM and writes: “Hello!”

and resource manager should return to the client:
“Hello! has been received.”

Using the examples of RM’s in the manuals I managed to
write and read to/from a RM, but independently, i.e. I can write
Hello!, but if I perform a read(…) I got back an empty string.
If I do the read without the write I can get
“has been received.”

You need to maintain context between the two function calls; the
read() and the write(). Read up on OCBs :slight_smile:

Cheers,
-RK


Robert Krten, PARSE Software Devices +1 613 599 8316.
Realtime Systems Architecture, Books, Video-based and Instructor-led
Training and Consulting at www.parse.com.
Email my initials at parse dot com.

Hi,
Interesting is you answering I got your book on my desk, by the way… :slight_smile:

That’s my problem how?
What I’m doing wrong?

I called the stuff needed for the read
with the context and stuff passed to the write() func

Assuming my simple io_write(…) func works perfectly
what is the bit I have to insert to call the stuff for the read
could you drop for me the 2-3lines that will do that bit???

Cheers


“Robert Krten” <nospam88@parse.com> wrote in message
news:actnop$lf5$1@inn.qnx.com

juan carlos <> jcd@dcs.st-and.ac.uk> > wrote:
Hi all,

I’m trying to write a simple Resorce Manager that
accepts a string from a client and returns another
string that simply says that the string has been received

Example:

A client Java program using standard I/O funcs opens the
RM and writes: “Hello!”

and resource manager should return to the client:
“Hello! has been received.”

Using the examples of RM’s in the manuals I managed to
write and read to/from a RM, but independently, i.e. I can write
Hello!, but if I perform a read(…) I got back an empty string.
If I do the read without the write I can get
“has been received.”


You need to maintain context between the two function calls; the
read() and the write(). Read up on OCBs > :slight_smile:

Cheers,
-RK


Robert Krten, PARSE Software Devices +1 613 599 8316.
Realtime Systems Architecture, Books, Video-based and Instructor-led
Training and Consulting at > www.parse.com> .
Email my initials at parse dot com.

Thanks Robert for your help

I sorted it out! the code was ok, but I forgot to change the
name of a var in a statement I was using the wrong one!
you know one of those things!!
It couldn’t be that difficult!

Cheers anyway!

JcD



“juan carlos” <jcd@dcs.st-and.ac.uk> wrote in message
news:actnlj$lep$1@inn.qnx.com

Hi all,

I’m trying to write a simple Resorce Manager that
accepts a string from a client and returns another
string that simply says that the string has been received

Example:

A client Java program using standard I/O funcs opens the
RM and writes: “Hello!”

and resource manager should return to the client:
“Hello! has been received.”

Using the examples of RM’s in the manuals I managed to
write and read to/from a RM, but independently, i.e. I can write
Hello!, but if I perform a read(…) I got back an empty string.
If I do the read without the write I can get
“has been received.”

Thanks

Juan Carlos

juan carlos <jcd@dcs.st-and.ac.uk> wrote:

Hi,
Interesting is you answering I got your book on my desk, by the way… > :slight_smile:

Well, that’s why you can’t get it running, you’re reading my book! :slight_smile: :slight_smile:

That’s my problem how?
What I’m doing wrong?

I called the stuff needed for the read
with the context and stuff passed to the write() func

Assuming my simple io_write(…) func works perfectly
what is the bit I have to insert to call the stuff for the read
could you drop for me the 2-3lines that will do that bit???

The trick is, that you need to store the data somewhere. Let’s assume
that the write() drops the string into a buffer, let’s call it
global_buff[]. The read() then needs to get the data from that
buffer. So, in your io_write() function, you need to get the data
from the client, and put it into global_buff[]. You can stick in a
printf() to ensure that the data really does come from the client
and that you got it all.

Then, in your io_read(), you need to figure out (as per the examples
in the book) how big the client’s buffer is and how many bytes you
have sitting in global_buff[]…

This is actually a nasty piece of business, because you will now run
into synchronization problems – what if two clients write() to your
resource manager, and then, out of order, they both read() from the
resmgr? Since in this example we’ve stored the data in a global
buffer, there’s no “per-client” storage area…

If you think about it further, what you’re doing is definitely not
like a file – if I open a file and write to it, I expect to be able
to read back exactly what I wrote, not the “xxx has been received.”
message.

The OCB suggestion will only work if you don’t close the file
between the write() and the read(). If you do, the OCB stuff
will evaporate into thin air…

So, the question boils down to “where do you store the string” in
the resource manager? Verify that you actually got the data from
the client’s write() (via printf()) first…

Hope this helps!
Cheers,
-RK

Cheers



“Robert Krten” <> nospam88@parse.com> > wrote in message
news:actnop$lf5$> 1@inn.qnx.com> …
juan carlos <> jcd@dcs.st-and.ac.uk> > wrote:
Hi all,

I’m trying to write a simple Resorce Manager that
accepts a string from a client and returns another
string that simply says that the string has been received

Example:

A client Java program using standard I/O funcs opens the
RM and writes: “Hello!”

and resource manager should return to the client:
“Hello! has been received.”

Using the examples of RM’s in the manuals I managed to
write and read to/from a RM, but independently, i.e. I can write
Hello!, but if I perform a read(…) I got back an empty string.
If I do the read without the write I can get
“has been received.”


You need to maintain context between the two function calls; the
read() and the write(). Read up on OCBs > :slight_smile:

Cheers,
-RK


Robert Krten, PARSE Software Devices +1 613 599 8316.
Realtime Systems Architecture, Books, Video-based and Instructor-led
Training and Consulting at > www.parse.com> .
Email my initials at parse dot com.


Robert Krten, PARSE Software Devices +1 613 599 8316.
Realtime Systems Architecture, Books, Video-based and Instructor-led
Training and Consulting at www.parse.com.
Email my initials at parse dot com.

juan carlos <jcd@dcs.st-and.ac.uk> wrote:

Thanks Robert for your help

I sorted it out! the code was ok, but I forgot to change the
name of a var in a statement I was using the wrong one!
you know one of those things!!
It couldn’t be that difficult!

D’oh an I just replied :slight_smile:

Cheers,
-RK

Cheers anyway!

JcD



“juan carlos” <> jcd@dcs.st-and.ac.uk> > wrote in message
news:actnlj$lep$> 1@inn.qnx.com> …
Hi all,

I’m trying to write a simple Resorce Manager that
accepts a string from a client and returns another
string that simply says that the string has been received

Example:

A client Java program using standard I/O funcs opens the
RM and writes: “Hello!”

and resource manager should return to the client:
“Hello! has been received.”

Using the examples of RM’s in the manuals I managed to
write and read to/from a RM, but independently, i.e. I can write
Hello!, but if I perform a read(…) I got back an empty string.
If I do the read without the write I can get
“has been received.”

Thanks

Juan Carlos
\


Robert Krten, PARSE Software Devices +1 613 599 8316.
Realtime Systems Architecture, Books, Video-based and Instructor-led
Training and Consulting at www.parse.com.
Email my initials at parse dot com.