| 9 | |
| 10 | |
| 11 | UDPSender::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 | |
| 37 | UDPSender::~UDPSender() |
| 38 | { |
nothing calls this directly
no outgoing calls
no test coverage detected