// 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
testmarshall()
{
marshall m;
- req_header rh(1,2,3,4,5);
+ request_header rh{1,2,3,4,5};
m.pack_req_header(rh);
VERIFY(m.size()==RPC_HEADER_SZ);
int i = 12345;
VERIFY(sz == (int)(RPC_HEADER_SZ+sizeof(i)+sizeof(l)+s.size()+sizeof(int)));
unmarshall un(b,sz);
- req_header rh1;
+ request_header rh1;
un.unpack_req_header(&rh1);
VERIFY(memcmp(&rh,&rh1,sizeof(rh))==0);
int i1;
int xx = 0;
intret = c->call_timeout(23, rpcc::to(3000), xx, 77);
VERIFY(intret == 0 && xx == 78);
- printf(" -- no suprious timeout .. ok\n");
+ printf(" -- no spurious timeout .. ok\n");
// specify a timeout value to an RPC that should succeed (tcp)
{
std::string rep;
c->call_timeout(22, rpcc::to(3000), rep, arg, (std::string)"x");
VERIFY(rep.size() == 1001);
- printf(" -- no suprious timeout .. ok\n");
+ printf(" -- no spurious timeout .. ok\n");
}
// huge RPC