if (libtcp_receive_bin(sockfd, &ret, sizeof(uint8_t)) != sizeof(uint8_t))
throw std::runtime_error("Error al recibir ret por socket");
uint8_t count;
- if (libtcp_send(sockfd, &count, sizeof(uint8_t)) != sizeof(uint8_t))
+ if (libtcp_receive_bin(sockfd, &count, sizeof(uint8_t)) != sizeof(uint8_t))
throw std::runtime_error("Error al recibir count por socket");
ips.clear();
ips.reserve(count);
for (uint8_t i = 0; i < count; ++i)
{
uint32_t ip;
- if (libtcp_send(sockfd, &ip, sizeof(uint32_t)) != sizeof(uint32_t))
+ if (libtcp_receive_bin(sockfd, &ip, sizeof(uint32_t)) != sizeof(uint32_t))
throw std::runtime_error("Error al recibir IPAddr por socket");
ips.push_back(ip);
}
/// Impresión de response
std::ostream& operator<< (std::ostream& os, const ResolvProtoResponse& rpr)
{
+ if (rpr.ips.empty())
+ return os;
os << "ResolvProtoResponse(ret=" << unsigned(rpr.ret) << ", ";
- std::copy(rpr.ips.begin(), rpr.ips.end(),
+ std::copy(rpr.ips.begin(), rpr.ips.end() - 1,
std::ostream_iterator< IPAddr >(os, ", "));
- return os << ")";
+ return os << rpr.ips.back() << ")";
}
// vim: set et sw=4 sts=4 :