문제

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의 문제가 있거나 다른 일을하는 것입니까?

SRV 쿼리를 www.example.com에 수행하려고 시도했습니다.

도움이 되었습니까?

해결책

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