-
Notifications
You must be signed in to change notification settings - Fork 0
/
message_test.cpp
93 lines (86 loc) · 2.6 KB
/
message_test.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#include "Message.h"
// #include "Client.h"
#include <iostream>
#include <string>
#include <ctime>
#include <chrono>
#include <sys/time.h>
#include <unistd.h>
#include <queue>
using namespace std::chrono;
using namespace std;
// int passw(Message* m)
// {
// cout<<m->getMessage()<<endl;
// }
// int pass(Message* m)
// {
// passw(m);
// cout<<"I am here1"<<endl;
// }
int main(int argc, char ** argv)
{
// char * ip= argv[1];
// int port = stoi(argv[2]);
// Client c(ip,port);
// bool stop = false;
// string input;
// while(!stop && input != "q")
// {
// cin >> input;
// char * str = new char[input.size()];
// strcpy(str, input.c_str());
// Message *m =new Message(Request, 1, 3, "10.1", "10.2", 6666, 9, 8, input.size(), str);
// int stat = pass(m);
// //c.setTimeout(0, 10000);
// c.Send(m);
// }
// Client c(ip,port);
// c.setTimeout(0, 10000);
// string input = "";
//while(!stop)
// {
// cout << "Client main: before send" << endl;
// cin >> input;
// char * str = new char[input.size()];
// strcpy(str, input.c_str());
// Message * m;
// int status = c.Send(m);
// cout << "Client main: after send" << endl;
// }
clock_t t1 = 0;
while(true)
{
seconds ms = duration_cast< seconds >( system_clock::now().time_since_epoch());
long long timeStamp = ms.count();
Message *m = new Message(Request, 1, 3, "10.1", 3, "10.2", 6666, 9, 8, 10, "MEEEEEEEEH");
char * s = new char [1024];
s = m->marshal();
Message newM(s);
cout << newM.getMessageType()<< endl;
cout << newM.getFragmentCount()<< endl;
cout << newM.getFragmentTotal()<< endl;
cout << newM.getSourceIP()<< endl;
cout << newM.getSourcePort()<< endl;
cout << newM.getDestinationIP()<< endl;
cout << newM.getDestinationPort()<< endl;
cout << newM.getRPCId()<< endl;
cout << newM.getOperation()<< endl;
cout << newM.getMessageSize()<< endl;
cout << newM.getMessage()<< endl;
cout << newM.getMessageTimestamp() << endl;
//usleep(1000000);
}
// bool stop = false;
// Message *m =new Message(Request, 1, 3, "10.1", "10.2", 6666, 9, 8, 10, "MEEEEEEEEH");
// // pass(m);
// cout<<"I am out"<<endl;
// cout << "Client main: before send" << endl;
// cin >> input;
// // char * str = new char[input.size()];
// // strcpy(str, input.c_str());
// cout<<"I am here";
// int status = c.Send(m);
// cout << "Client main: after send" << endl;
return 0;
}