[go: up one dir, main page]

Menu

[r64]: / gmp / gs.cpp  Maximize  Restore  History

Download this file

39 lines (27 with data), 665 Bytes

 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
#include <gmp.h>
#include <message.h>
#include <iostream>
using namespace std;
using namespace cb;
int main()
{
cb::CGMP gmp;
gmp.init(6000);
char ip[64];
int port;
CUserMessage msg;
int32_t id;
char* res = "got it.";
strcpy(msg.m_pcBuffer, res);
msg.m_iDataLength = strlen(res) + 1;
while (true)
{
gmp.recvfrom(ip, port, id, &msg);
cout << "RECV " << ip << " " << port << " " << id << " " << msg.m_pcBuffer << " " << msg.m_iDataLength << endl;
strcpy(msg.m_pcBuffer, res);
msg.m_iDataLength = strlen(res) + 1;
gmp.sendto(ip, port, id, &msg);
cout << endl << endl;
}
return 1;
}