-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcpp-rpc.cpp
More file actions
28 lines (24 loc) · 805 Bytes
/
cpp-rpc.cpp
File metadata and controls
28 lines (24 loc) · 805 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include "stdafx.h"
#include "example_rpc.h"
int example::add(int a, int b) { return a + b; }
double example::add(double a, double b) { return a + b; }
int example::add(int a, int b, int c) { return a + b + c; }
int _tmain(int argc, _TCHAR* argv[])
{
boost::asio::io_service io_service;
example::example_rpc_server_t server(io_service, 12345);
server.request_accept();
example::example_rpc_client_t client(io_service);
client.connect("127.0.0.1", 12345);
client.add(10, 20, [] (int result) {
std::cout << result << std::endl;
});
client.add(11.5, 23.7, [] (double result) {
std::cout << result << std::endl;
});
client.add(10, 20, 30, [] (int result) {
std::cout << result << std::endl;
});
io_service.run();
return 0;
}