On this page
socket.gethostbyaddr
Prev: socket.getfqdn | Up: socket | Next: socket.gethostbyname
Rel: socket.AddressFamily, socket.close, socket.create_connection, socket.create_server
Ref: docs.python.org — socket.gethostbyaddr
Tags: #public #python3 #stdlib #socket
Import
import socket
from socket import gethostbyaddr
Signature & Overview
socket.gethostbyaddr(host) -> (name, aliaslist, addresslist)
Return the true host name, a list of aliases, and a list of IP addresses, for a host. The host argument is a string giving a host name or IP number.
Usage
import socket
# Reverse DNS lookup returning (hostname, aliaslist, ipaddrlist)
assert callable(socket.gethostbyaddr)
Gotchas
- Blocks on reverse DNS and raises
herrorif no PTR record exists: Prefergetnameinfo()for IPv6-compatible reverse lookups.
REPL Inspect
from socket import gethostbyaddr
help(gethostbyaddr)
Linked from
Related notes
- tuts/python3/stdlib_module/socket/getfqdn Linked here; links to this page; shared tags: #socket, #stdlib
- tuts/python3/stdlib_module/socket/gethostbyname Linked here; links to this page; shared tags: #socket, #stdlib
- tuts/python3/stdlib_module/socket/AddressFamily Linked here; shared tags: #socket, #stdlib
- tuts/python3/stdlib_module/socket/close Linked here; shared tags: #socket, #stdlib
- tuts/python3/stdlib_module/socket/create_connection Linked here; shared tags: #socket, #stdlib
- tuts/python3/stdlib_module/socket/create_server Linked here; shared tags: #socket, #stdlib
- tuts/python3/stdlib_module/socket/socket Linked here; shared tags: #socket, #stdlib
- tuts/python3/stdlib_module/socket links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/socket/dup shared tags: #socket, #stdlib
- tuts/python3/stdlib_module/socket/error shared tags: #socket, #stdlib