RPC question

R

Razzle

Hi!

I'm working on a RPC application, but since I tried to make my code
multithreaded I have a few problems passing strings.

If I have a .x file like this one:

program RCPROG {
version REMOTECOMPILEVERS {
int CREATEFILE(string) = 1;
string TEST(int) = 2;
} = 1;
} = 0x20000001;

and TEST is defined in the server program like this:

bool_t test_1_svc(int*somearg, char **result, struct svc_req *rgstp)

I should be able to pass a string to result_2 (from the invocation of
test_1 in the client program:

char *result_2;
result_2 = (char *)malloc(256);
retval_2 = test_1(&xx,&result_2, clnt);

)like this:

strcpy(*result, "bla");

Right?
Either I'm just too blind to see an obvious mistake I made or I should
go back to basics..
All I want is that the client receives a string as result from
invoking test_1.

(Google didn't help much on this issue because nothing I found dealt
with returning strings in multithreaded mode)
 
J

Jack Klein

Hi!

I'm working on a RPC application, but since I tried to make my code
multithreaded I have a few problems passing strings.

You need to take RPC issues to a support group for your particular
compiler/operating system combination. It is not a C language
question, but rather about the extensions your platform provides for
doing this sort of thing. C itself does not define or support RPC.

On the other hand, you might have an actual C problem, so I'll add a
few comments.
If I have a .x file like this one:

program RCPROG {
version REMOTECOMPILEVERS {
int CREATEFILE(string) = 1;
string TEST(int) = 2;
} = 1;
} = 0x20000001;

and TEST is defined in the server program like this:

bool_t test_1_svc(int*somearg, char **result, struct svc_req *rgstp)

I should be able to pass a string to result_2 (from the invocation of
test_1 in the client program:

char *result_2;
result_2 = (char *)malloc(256);

Don't cast the pointer returned by malloc(), it is not necessary in C
and can prevent important compiler warnings.
retval_2 = test_1(&xx,&result_2, clnt);

You haven't shown us the definitions of xx and clnt, which is supposed
to be a pointer to a struct, according to the prototype. Do you test
the value returned by the function? What are the consequences if it
indicates a failure?
)like this:

strcpy(*result, "bla");

What is result? Above you showed the definition of result_2, but you
haven't shown anything about result.
Right?
Either I'm just too blind to see an obvious mistake I made or I should
go back to basics..
All I want is that the client receives a string as result from
invoking test_1.

(Google didn't help much on this issue because nothing I found dealt
with returning strings in multithreaded mode)

C doesn't have a "multithreaded mode". Again, a platform specific
group is what's needed here.

There is so much missing information and non-standard extensions in
your post that I can't tell if you have a real C problem or not.
 
C

CBFalconer

Razzle said:
I'm working on a RPC application, but since I tried to make my
code multithreaded I have a few problems passing strings.
.... snip ...

char *result_2;
result_2 = (char *)malloc(256); ^^^^^^^^
retval_2 = test_1(&xx,&result_2, clnt);
^

RPC is way off topic. However you may have a C question. At any
rate I suspect the two deletions marked above will help.

Next time post compilable short programs that do not include any
non-standard items. If you don't know how to tell standard from
non-standard ask, but any decent set of man or info pages will
tell you. POSIX is NOT standard C. Windoze is NOT standard C.
 
R

Razzle

Jack Klein said:
On 17 Feb 2004 16:53:09 -0800, (e-mail address removed) (Razzle) wrote in
comp.lang.c:


You need to take RPC issues to a support group for your particular
compiler/operating system combination. It is not a C language
question, but rather about the extensions your platform provides for
doing this sort of thing. C itself does not define or support RPC.
Ok I'll do this after replying to your post.
Don't cast the pointer returned by malloc(), it is not necessary in C
and can prevent important compiler warnings.

U changed that, no new errors..
You haven't shown us the definitions of xx and clnt, which is supposed
to be a pointer to a struct, according to the prototype. Do you test
the value returned by the function? What are the consequences if it
indicates a failure?
int xx;
CLIENT *clnt;

result_2 is NULL when the function returns. It takes extraordinary
long to return by the way which is strange..
C doesn't have a "multithreaded mode". Again, a platform specific
group is what's needed here.
I was referring to the option I used for rpcgen which is -M for
MT-safe code.
 

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

Members online

No members online now.

Forum statistics

Threads
474,140
Messages
2,570,810
Members
47,357
Latest member
sitele8746

Latest Threads

Top