0
A
回答
3
這裏有一個例子:
var http = require('http'),
dns = require('dns');
http.createServer(function (req, res) {
var ip = req.connection.remoteAddress;
res.writeHead(200, {'Content-Type': 'text/html'});
dns.reverse(ip, function(err, hostnames) {
res.write("Ip: " + ip + "<br />");
res.end("Your hostname(s) are " + hostnames.join("; "));
});
}).listen(1337, '127.0.0.1');
console.log('Server running at http://127.0.0.1:1337/');
閱讀官方Node.js的文檔網站更多: http://nodejs.org/docs/v0.6.18/api/dns.html#dns_dns_reverse_ip_callback
-1
您是否嘗試過搜索Node.js documentation?
相關問題
- 1. 如何在java中獲取連接客戶端的主機名?
- 2. Django獲取客戶端的域名/主機名
- 3. Spring Boot - 獲取spring.kafka客戶端的application.properties中的主機名
- 4. 獲取客戶端計算機名稱
- 5. 通過javascript或jquery獲取客戶端電腦的主機名
- 6. 如何在c#和asp.net中獲取客戶端主機名,本地計算機名稱和用戶名
- 7. Python無法打印客戶端IP或客戶端主機名
- 8. 以strus2格式獲取客戶端的用戶名和主機名
- 9. Windows DHCP客戶端主機名編碼
- 10. 獲取用戶主機名
- 11. 獲取客戶端IP內部中間件本地主機
- 12. SMTP客戶端多主機
- 13. 客戶端主機 - JavaMail的
- 14. 如何從phoenix中的websocket傳輸獲取客戶端數據(IP,主機名)?
- 15. c#獲取客戶端用戶名
- 16. 獲取客戶端IP和計算機的用戶名
- 17. 獲取客戶端IP的客戶端
- 18. 獲取客戶端機器ID
- 19. 如何實現Java RMI以獲取未連接的客戶端ip /主機名
- 20. C++ Pipe [如何獲取連接客戶端的IP地址或主機名。]
- 21. 獲取通過WCF進行調用的客戶端的主機名?
- 22. 有沒有辦法通過cherrypy服務器獲取客戶端主機名
- 23. Rails獲取客戶端的名稱
- 24. Web客戶端DownloadFileCompleted獲取文件名
- 25. 在ruby中獲取域名主機名
- 26. 在linq中獲取基於客戶端的用戶登錄名?
- 27. Java服務器客戶端和主機名稱計算機
- 28. 從IP獲取客戶機名稱
- 29. 如何從JavaScript獲取終端服務客戶機名稱?
http://stackoverflow.com/questions/4255264/getting-client-hostname-in -node-JS 請選中該 – abhijit