#include "Test.h" #include "UDP.h" using namespace std; void Udp_Test() { //UDP uint16_t port = 8900; UDPReceiver udpReceiver(port); udpReceiver.start_receiving([](const std::vector &date, sockaddr_in sockAdd, socklen_t socklen){ string da(date.begin(), date.end()); cout << inet_ntoa(sockAdd.sin_addr) << ":" << ntohs(sockAdd.sin_port) << endl; cout << da << endl; }); UDPSender udpSenderA(udpReceiver.sockfd_); udpSenderA.set_destination("127.0.0.1", 8200); UDPSender udpSenderB(udpReceiver.sockfd_); udpSenderB.set_destination("127.0.0.1", 8201); UDPSender udpSenderC(udpReceiver.sockfd_); udpSenderC.set_destination("127.0.0.1", 8200); while (true) { udpSenderA.send("helloA"); udpSenderB.send("B"); udpSenderC.send("C"); _sleep(5000); } }