// from multiple classes.
class srv {
public:
- int handle_22(const std::string a, const std::string b, std::string & r);
- int handle_fast(const int a, int &r);
- int handle_slow(const int a, int &r);
- int handle_bigrep(const int a, std::string &r);
+ int handle_22(std::string & r, const std::string a, const std::string b);
+ int handle_fast(int &r, const int a);
+ int handle_slow(int &r, const int a);
+ int handle_bigrep(std::string &r, const int a);
};
// a handler. a and b are arguments, r is the result.
// at these argument types, so this function definition
// does what a .x file does in SunRPC.
int
-srv::handle_22(const std::string a, std::string b, std::string &r)
+srv::handle_22(std::string &r, const std::string a, std::string b)
{
r = a + b;
return 0;
}
int
-srv::handle_fast(const int a, int &r)
+srv::handle_fast(int &r, const int a)
{
r = a + 1;
return 0;
}
int
-srv::handle_slow(const int a, int &r)
+srv::handle_slow(int &r, const int a)
{
usleep(random() % 5000);
r = a + 2;
}
int
-srv::handle_bigrep(const int len, std::string &r)
+srv::handle_bigrep(std::string &r, const int len)
{
r = std::string(len, 'x');
return 0;
void startserver()
{
server = new rpcs(port);
- server->reg(22, &service, &srv::handle_22);
- server->reg(23, &service, &srv::handle_fast);
- server->reg(24, &service, &srv::handle_slow);
- server->reg(25, &service, &srv::handle_bigrep);
+ server->reg(22, &srv::handle_22, &service);
+ server->reg(23, &srv::handle_fast, &service);
+ server->reg(24, &srv::handle_slow, &service);
+ server->reg(25, &srv::handle_bigrep, &service);
}
void