-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient_main.cpp
More file actions
73 lines (56 loc) · 1.21 KB
/
Copy pathclient_main.cpp
File metadata and controls
73 lines (56 loc) · 1.21 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#include <iostream>
#include <fstream>
#include <string>
#include "client.h"
using namespace boost::asio;
using namespace boost::asio::ip;
using namespace boost::multiprecision;
using namespace alert::bignums;
using namespace std;
int main(int nargs, char *args[])
{
if (nargs<3)
{
cout << "Se requiere el puerto y la ruta completa del archivo de datos" << endl << endl;
}
else
{
std::vector<uint1024_t> nums;
nums.clear();
int port = atoi(args[1]);
io_service io;
std::string line;
std::ifstream dataFile(args[2]);
if (dataFile.is_open())
{
while (getline(dataFile, line))
{
cout << line << '\n';
uint1024_t num(line);
nums.push_back(num);
}
dataFile.close();
}
if (nums.size() > 0)
{
Client client(io, "127.0.0.1", port);
std::cout << "Client conected to port: " << port << std::endl;
auto resp = client.sort_and_sum(nums);
/**
* response is array of nums.size + 1
* firs element is sum
* other elements vector sorted
*/
std::cout << "Response vector size: " << resp.size() << std::endl;
for (auto& r : resp)
{
std::cout << r << std::endl;
}
}
else
{
std::cout << "empty vector" << std::endl;
}
}
return 0;
}