Perché SRV Res_Query restituisce sempre -1?
Domanda
Sto cercando di implementare una semplice query SRV DNS utilizzando res_query
.Il mio codice per la parte res_query sta seguendo:
char* target;
short* port;
union {
HEADER hdr;
u_char buf[1024];
} response;
ns_msg handle;
ns_rr rr;
u_char buf[256], *p;
int t, len, priority, weight;
if ((len = res_query(query, C_IN, ns_t_srv, (u_char *)&response, sizeof(response))) <0 ) {
cout << "res_query returned -1, no answer" << endl;
return 0;
}
.
Questa è solo una parte del codice, ma immagino che ci siano tutte le cose richieste per fare il res_query
.Ogni volta che eseguo la query SRV, Res_Query restituisce '-1', il che significa che fallisce.È il problema nella mia res_query o sto facendo qualcos'altro sbagliato?
Ho provato a fare la query SRV a www.example.com
.
Soluzione
res_query
will return -1 if no matching record is found.
Apart from that your code works fine for me, although OSX requires ns_c_in
instead of C_IN
.
Try testing with _nicname._tcp.us.
instead of www.example.com
.
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow