-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathecho_client.cpp
54 lines (46 loc) · 1.03 KB
/
echo_client.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
45
46
47
48
49
50
51
52
53
// echo_client.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#ifdef _MSC_VER
#pragma comment(lib, "Ws2_32.lib")
#endif
#include <stdio.h>
#include <nark/rpc/client.hpp>
#include <nark/inet/SocketStream.hpp>
#include <iostream>
using namespace std;
using namespace nark;
using namespace nark::rpc;
#include "../echo.h"
int main0(int argc, char* argv[])
try {
auto_ptr<SocketStream> cs(ConnectSocket("127.0.0.1:8001"));
rpc_client<PortableDataInput, PortableDataOutput> client(cs.get());
EchoPtr ec = client.create("echo");
while (!cin.eof())
{
string msg, y;
cin >> msg;
ec->echo(msg, &y);
cout << "msg:" << msg << endl;
cout << "y__:" << y << endl;
}
return 0;
}
catch (const std::exception& exp)
{
printf("exception: what=%s\n", exp.what());
return 1;
}
int main(int argc, char* argv[])
{
#if defined(_WIN32) || defined(_WIN64)
WSADATA information;
WSAStartup(MAKEWORD(2, 2), &information);
int ret = main0(argc, argv);
WSACleanup();
return ret;
#else
return main0(argc, argv);
#endif
}