|
@@ -66,6 +66,7 @@ void udpsocket::write(const std::vector<char>& msg, const std::string& dest, int
|
|
memcpy(&server_addr.sin_addr, server_host->h_addr,
|
|
memcpy(&server_addr.sin_addr, server_host->h_addr,
|
|
sizeof(struct in_addr)); server_addr.sin_port = htons(port);
|
|
sizeof(struct in_addr)); server_addr.sin_port = htons(port);
|
|
/* send a message */
|
|
/* send a message */
|
|
|
|
+ while(true)
|
|
if(sendto(s, msg.data(), msg.size(), 0,(const sockaddr*)&server_addr, sizeof(server_addr)) < 0){
|
|
if(sendto(s, msg.data(), msg.size(), 0,(const sockaddr*)&server_addr, sizeof(server_addr)) < 0){
|
|
throw std::logic_error(std::string("Could not send packet: ") + strerror(errno));
|
|
throw std::logic_error(std::string("Could not send packet: ") + strerror(errno));
|
|
}
|
|
}
|
|
@@ -87,9 +88,9 @@ void die(const std::string& s) {
|
|
|
|
|
|
int main() {
|
|
int main() {
|
|
udpsocket sock(5566);
|
|
udpsocket sock(5566);
|
|
- std::vector<char> d(23,'a');
|
|
|
|
|
|
+ std::vector<char> d(512,'a');
|
|
while(true)
|
|
while(true)
|
|
- sock.write(d.data(), "127.0.0.1" ,5555);
|
|
|
|
|
|
+ sock.write(d.data(), "8.8.8.8" ,5555);
|
|
std::cin.get();
|
|
std::cin.get();
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|