MCPcopy Create free account
hub / github.com/AIRLegend/aitrack / UDPSender

Method UDPSender

Client/src/model/UDPSender.cpp:11–35  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9
10
11UDPSender::UDPSender(const char* dest_ip, int dest_port)
12{
13
14 this->ip = std::string(dest_ip);
15
16 std::cout << "from sender, the ip is " << this->ip << std::endl;
17
18 this->port = dest_port;
19
20 dest = sockaddr_in();
21 local = sockaddr_in();
22
23 WSAStartup(MAKEWORD(2, 2), &data);
24
25 local.sin_family = AF_INET;
26 inet_pton(AF_INET, dest_ip, &local.sin_addr.s_addr);
27 local.sin_port = htons(0);
28
29 dest.sin_family = AF_INET;
30 inet_pton(AF_INET, dest_ip, &dest.sin_addr.s_addr);
31 dest.sin_port = htons(dest_port);
32
33 s = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
34 bind(s, (sockaddr*)&local, sizeof(local));
35}
36
37UDPSender::~UDPSender()
38{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected