X-Git-Url: https://git.llucax.com/z.facultad/75.74/practicos.git/blobdiff_plain/46098de47811c686844e5cb8b1d8f1b59586e6b8..63516fdd4cb64b01971750be1d29d7244b1f9e5e:/practicas/pipi/src/resolvproto.cpp?ds=inline diff --git a/practicas/pipi/src/resolvproto.cpp b/practicas/pipi/src/resolvproto.cpp index e711004..4c45f69 100644 --- a/practicas/pipi/src/resolvproto.cpp +++ b/practicas/pipi/src/resolvproto.cpp @@ -54,6 +54,11 @@ std::ostream& operator<< (std::ostream& os, const ResolvProtoRequest& rpr) << ", name=" << rpr.name << ")"; } +/// Constructor +ResolvProtoResponse::ResolvProtoResponse(): ret(R_NOTFOUND), ttl(0) +{ +} + /// Constructor ResolvProtoResponse::ResolvProtoResponse(int fd) { @@ -61,8 +66,9 @@ ResolvProtoResponse::ResolvProtoResponse(int fd) } /// Constructor -ResolvProtoResponse::ResolvProtoResponse(ret_t ret, uint32_t ttl): - ret(ret), ttl(ttl) +ResolvProtoResponse::ResolvProtoResponse(ret_t ret, uint32_t ttl, + const ipvec_t& ips): + ret(ret), ttl(ttl), ips(ips) {} /// Envía por socket @@ -109,10 +115,11 @@ void ResolvProtoResponse::recv(int sockfd) /// 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) - << ", ttl=" << rpr.ttl << ", "; + << ", ttl=" << rpr.ttl; + if (rpr.ips.empty()) + return os << ")"; + os << ", "; std::copy(rpr.ips.begin(), rpr.ips.end() - 1, std::ostream_iterator< IPAddr >(os, ", ")); return os << rpr.ips.back() << ")";