-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.cpp
executable file
·75 lines (61 loc) · 2.03 KB
/
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
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
/* ***********************************************
MYID : Chen Fan
LANG : G++
PROG : RDMA_MAIN
************************************************ */
#include "src/rdma_util.h"
#include "src/rdma_session.h"
#include "src/rdma_endpoint.h"
#include "src/tcp_sock_pre.h"
int main(int argc, char* argv[])
{
if (argc == 1)
{
log_error("Missing Start Up Config");
log_error("Usage:");
log_error("xxx s\tto start the server");
log_error("xxx c\tto start the client");
} else
{
TCP_Sock_Pre pre_tcp;
// Connect
if (strcmp(argv[1], "s") == 0)
{
log_ok("Server Start");
} else if (strcmp(argv[1], "c") == 0)
{
log_ok("Client Start");
if (argc == 2) pre_tcp.config.server_name = LOCALHOST;
else pre_tcp.config.server_name = argv[2];
}
RDMA_Session session;
//RDMA_Endpoint* endpoint = session.ptp_connect(&pre_tcp);
if (strcmp(argv[1], "s") == 0)
{
session.daemon_connect(&pre_tcp);
// RDMA_Endpoint* endpoint = pre_tcp.ptp_connect(&session);
// char a[] = "Hello World from Server !!!!!";
// endpoint->send_data((void*)a, sizeof(a));
log_ok("Ready to Transport\n");
} else if (strcmp(argv[1], "c") == 0)
{
RDMA_Endpoint* endpoint = session.ptp_connect(&pre_tcp);
log_ok("Ready to Transport\n");
char a[] = "Hello World from Client !!!!!";
endpoint->send_rawdata((void*)a, sizeof(a));
char b[] = "Test Test Test Test Test Test Test Test Test";
while (1)
{
int com;
std::cin >> com;
if (com == 0) endpoint->send_rawdata((void*)b, sizeof(b));
else
{
endpoint->close();
break;
}
}
}
}
return 0;
}