On this page
socket.inet_aton
Prev: socket.if_nametoindex | Up: socket | Next: socket.inet_ntoa
Rel: socket.AddressFamily, socket.close, socket.create_connection, socket.create_server
Ref: docs.python.org — socket.inet_aton
Tags: #public #python3 #stdlib #socket
Import
import socket
from socket import inet_aton
Signature & Overview
socket.inet_aton(ip_addr, /)
Convert an IP address in string format (123.45.67.89) to the 32-bit packed binary format used in low-level network functions.
Usage
import socket
assert socket.inet_aton("127.0.0.1") == b"\x7f\x00\x00\x01"
Gotchas
- IPv4-only and accepts shorthand like
"127.1": Preferinet_pton(AF_INET, ...)or the ipaddress module for strict parsing and IPv6 support.
REPL Inspect
from socket import inet_aton
help(inet_aton)
Linked from
Related notes
- tuts/python3/stdlib_module/socket/if_nametoindex Linked here; links to this page; shared tags: #socket, #stdlib
- tuts/python3/stdlib_module/socket/inet_ntoa 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/ipaddress Linked here; shared tags: #stdlib
- tuts/python3/stdlib_module/socket links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/socket/dup shared tags: #socket, #stdlib