Networking and Internet Modules
socket
Low-level socket interfaces for byte streams and datagrams. Address families identify addressing conventions; stream sockets do not preserve message boundaries. This example converts an IPv4 address without opening a connection. Use explicit timeouts and close sockets in real programs.
Formal Syntax & Structure
python syntaxpython
import socketReturn Value
module
Module namespace available through import; import is a statement, not a value-returning expression.
Working Example
Example Snippetpython
import socketprint(socket.inet_pton(socket.AF_INET, "192.0.2.1").hex())