-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
44 lines (33 loc) · 1010 Bytes
/
main.cpp
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include <memory>
#include <string>
#include <grpc++/grpc++.h>
#include "protos/test.grpc.pb.h"
using grpc::Status;
using grpc::ServerContext;
using grpc::ServerBuilder;
using grpc::Server;
using test::Request;
using test::Reply;
using test::testService;
class RouteGuideImpl final : public testService::Service {
Status TestGrpc(ServerContext *context, const Request* request,
Reply* reply) override {
reply->set_result(request->param());
return Status::OK;
}
};
void RunServer() {
std::string server_address("0.0.0.0:50051");
RouteGuideImpl service;
ServerBuilder builder ;
builder.AddListeningPort(server_address, grpc::InsecureServerCredentials());
builder.RegisterService(&service);
std::unique_ptr<Server> server(builder.BuildAndStart());
std::cout << "Server listening on " << server_address << std::endl;
server->Wait();
}
int main() {
std::cout << "Hello, World!" << std::endl;
RunServer();
return 0;
}