質問

res_queryを使用して単純なDNS SRVクエリを実装しようとしています。res_query部品のコードは次のとおりです。

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;
}
.

これはコードの一部ですが、res_queryを実行する必要があるすべてのことがあると思います。SRVクエリを実行するたびに、res_queryは '-1'を返し、それは失敗します。私のres_queryの問題は、他の何かが間違っていることをしていますか?

www.example.comにSRVクエリを実行しようとしました。

役に立ちましたか?

解決

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.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top