简体   繁体   中英

Error Running simpel RPC Program

I'm having trouble running the simplest RPC program. I want a program that will send a string from the client to a server and the server send the string back to the client. This is the echo.x:

program ECHO_PROG{
    version ECHO_VERS{
        string ECHO(string) = 1;
    } = 1;
} = 0x22233323;

After runnning rpcgen -a -C echo.x, I make the program and then I try to run

./echo_server &
./echo_client localhost

and I get the error :

call failed: RPC: Can't encode arguments. 

Am I declaring the correct argument types in the .x file? Why am I getting that error? If I want to send a string to the server and have it echoed back am I approaching the problem correctly? I understand how to create an RPC that will return an int but returning a string is confounding me deeply. Please help if you're out there!

Probably not happy returning a string... try this:

program ECHO_PROG{
    version ECHO_VERS{
        int ECHO(string) = 1;
    } = 1;
} = 0x22233323;

of course if the whole point is to return a string then you need to do some work -- I believe you have to wrap it in a custom type.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM