On this page
  1. socket.gethostbyname
  2. Import
  3. Signature & Overview
  4. Usage
  5. Gotchas
  6. REPL Inspect

socket.gethostbyname

Prev: socket.gethostbyaddr | Up: socket | Next: socket.gethostbyname_ex
Rel: socket.AddressFamily, socket.close, socket.create_connection, socket.create_server
Ref: docs.python.org — socket.gethostbyname
Tags: #public #python3 #stdlib #socket


Import

import socket
from socket import gethostbyname

Signature & Overview

socket.gethostbyname(host) -> address

Return the IP address (a string of the form '255.255.255.255') for a host.

Usage

import socket

ip = socket.gethostbyname("localhost")
assert ip.startswith("127.")

Gotchas

REPL Inspect

from socket import gethostbyname
help(gethostbyname)

Linked from

Related notes