On this page
socket.if_indextoname
Prev: socket.htons | Up: socket | Next: socket.if_nameindex
Rel: socket.AddressFamily, socket.close, socket.create_connection, socket.create_server
Ref: docs.python.org — socket.if_indextoname
Tags: #public #python3 #stdlib #socket
Import
import socket
from socket import if_indextoname
Signature & Overview
socket.if_indextoname(if_index, /)
Returns the interface name corresponding to the interface index if_index.
Usage
import socket
if hasattr(socket, "if_nameindex"):
idx, expected = socket.if_nameindex()[0]
assert socket.if_indextoname(idx) == expected
Gotchas
- Raises
OSErrorif no network interface has that index.
REPL Inspect
from socket import if_indextoname
help(if_indextoname)
Linked from
Related notes
- tuts/python3/stdlib_module/socket/htons Linked here; links to this page; shared tags: #socket, #stdlib
- tuts/python3/stdlib_module/socket/if_nameindex 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