Re: [問題] 將遠端IP解譯回主機名稱

看板C_and_CPP作者 (raison detre)時間12年前 (2011/12/21 09:18), 編輯推噓0(005)
留言5則, 3人參與, 最新討論串2/2 (看更多)
我使用了gethostbyaddr()測試之後 取得的主機名如下 'ANantes-651-1-49-net.w2-0.abo.wanadoo.fr' 這並不是我預期的答案 並且我是了好幾台狀況都一樣 請問這是對的嗎? 又請問在區網中 網路芳鄰與smb server的做法為何 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 61.220.71.34

12/20 22:15,
可以給一下你的code嗎@@? 搞不好你傳ip的使用方式是錯的
12/20 22:15

12/20 22:28,
DNS?
12/20 22:28
謝謝大家的幫忙 以下是我的code struct sockaddr_in _addr; memset(&_addr, 0, sizeof(struct sockaddr_in)); _addr.sin_family = AF_INET; _addr.sin_addr.s_addr = inet_addr(szIP.c_str()); struct hostent* _hptr = gethostbyaddr((const char*)&_addr,sizeof(struct sockaddr_in), AF_INET); if(_hptr==NULL) return; std::cout << _hptr->h_name << std::endl; int i=0; while(_hptr->h_aliases[i]!=NULL) {std::cout << _hptr->h_aliases[i++] << std::endl;} -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 61.220.71.34

12/21 10:22, , 1F
gethostbyaddr是要傳in_addr*不是sockaddr_in*吧 XD
12/21 10:22, 1F

12/21 10:41, , 2F
did you try "nslookup"? what's the result?
12/21 10:41, 2F

12/21 17:08, , 3F
nslookup 的結果是connection timed out; no servers cou
12/21 17:08, 3F

12/21 17:09, , 4F
請問這是否代表這個網域裡頭不能rdns?
12/21 17:09, 4F

12/22 19:11, , 5F
It's maybe the problem caused by dns-server. I suggest
12/22 19:11, 5F
文章代碼(AID): #1EyJFedL (C_and_CPP)
文章代碼(AID): #1EyJFedL (C_and_CPP)