17. Interprocess Communication and Networking¶
The modules described in this chapter provide mechanisms for different processes to communicate.
Some modules only work for two processes that are on the same machine, e.g.
signal
and subprocess
. Other modules support networking protocols
that two or more processes can use to communicate across machines.
The list of modules described in this chapter is:
- 17.1.
subprocess
— Subprocess management - 17.2.
socket
— Low-level networking interfaceerror
herror
gaierror
timeout
AF_UNIX
AF_INET
AF_INET6
SOCK_STREAM
SOCK_DGRAM
SOCK_RAW
SOCK_RDM
SOCK_SEQPACKET
SOMAXCONN
has_ipv6
create_connection()
getaddrinfo()
getfqdn()
gethostbyname()
gethostbyname_ex()
gethostname()
gethostbyaddr()
getnameinfo()
getprotobyname()
getservbyname()
getservbyport()
socket()
socketpair()
fromfd()
ntohl()
ntohs()
htonl()
htons()
inet_aton()
inet_ntoa()
inet_pton()
inet_ntop()
getdefaulttimeout()
setdefaulttimeout()
SocketType
- 17.2.1. Socket Objects
socket.accept()
socket.bind()
socket.close()
socket.connect()
socket.connect_ex()
socket.fileno()
socket.getpeername()
socket.getsockname()
socket.getsockopt()
socket.ioctl()
socket.listen()
socket.makefile()
socket.recv()
socket.recvfrom()
socket.recvfrom_into()
socket.recv_into()
socket.send()
socket.sendall()
socket.sendto()
socket.setblocking()
socket.settimeout()
socket.gettimeout()
socket.setsockopt()
socket.shutdown()
socket.family
socket.type
socket.proto
- 17.2.2. Example
- 17.3.
ssl
— TLS/SSL wrapper for socket objects- 17.3.1. Functions, Constants, and Exceptions
SSLError
SSLZeroReturnError
SSLWantReadError
SSLWantWriteError
SSLSyscallError
SSLEOFError
CertificateError
- 17.3.1.1. Socket creation
- 17.3.1.2. Context creation
- 17.3.1.3. Random generation
- 17.3.1.4. Certificate handling
- 17.3.1.5. Constants
CERT_NONE
CERT_OPTIONAL
CERT_REQUIRED
VERIFY_DEFAULT
VERIFY_CRL_CHECK_LEAF
VERIFY_CRL_CHECK_CHAIN
VERIFY_X509_STRICT
VERIFY_X509_TRUSTED_FIRST
PROTOCOL_TLS
PROTOCOL_SSLv23
PROTOCOL_SSLv2
PROTOCOL_SSLv3
PROTOCOL_TLSv1
PROTOCOL_TLSv1_1
PROTOCOL_TLSv1_2
OP_ALL
OP_NO_SSLv2
OP_NO_SSLv3
OP_NO_TLSv1
OP_NO_TLSv1_1
OP_NO_TLSv1_2
OP_NO_TLSv1_3
OP_CIPHER_SERVER_PREFERENCE
OP_SINGLE_DH_USE
OP_SINGLE_ECDH_USE
OP_ENABLE_MIDDLEBOX_COMPAT
OP_NO_COMPRESSION
HAS_ALPN
HAS_ECDH
HAS_SNI
HAS_NPN
HAS_TLSv1_3
CHANNEL_BINDING_TYPES
OPENSSL_VERSION
OPENSSL_VERSION_INFO
OPENSSL_VERSION_NUMBER
ALERT_DESCRIPTION_HANDSHAKE_FAILURE
ALERT_DESCRIPTION_INTERNAL_ERROR
Purpose.SERVER_AUTH
Purpose.CLIENT_AUTH
- 17.3.2. SSL Sockets
- 17.3.3. SSL Contexts
SSLContext
SSLContext.cert_store_stats()
SSLContext.load_cert_chain()
SSLContext.load_default_certs()
SSLContext.load_verify_locations()
SSLContext.get_ca_certs()
SSLContext.set_default_verify_paths()
SSLContext.set_ciphers()
SSLContext.set_alpn_protocols()
SSLContext.set_npn_protocols()
SSLContext.set_servername_callback()
SSLContext.load_dh_params()
SSLContext.set_ecdh_curve()
SSLContext.wrap_socket()
SSLContext.session_stats()
SSLContext.check_hostname
SSLContext.options
SSLContext.protocol
SSLContext.verify_flags
SSLContext.verify_mode
- 17.3.4. Certificates
- 17.3.5. Examples
- 17.3.6. Notes on non-blocking sockets
- 17.3.7. Security considerations
- 17.3.8. LibreSSL support
- 17.3.1. Functions, Constants, and Exceptions
- 17.4.
signal
— Set handlers for asynchronous events - 17.5.
popen2
— Subprocesses with accessible I/O streams - 17.6.
asyncore
— Asynchronous socket handlerloop()
dispatcher
dispatcher.handle_read()
dispatcher.handle_write()
dispatcher.handle_expt()
dispatcher.handle_connect()
dispatcher.handle_close()
dispatcher.handle_error()
dispatcher.handle_accept()
dispatcher.readable()
dispatcher.writable()
dispatcher.create_socket()
dispatcher.connect()
dispatcher.send()
dispatcher.recv()
dispatcher.listen()
dispatcher.bind()
dispatcher.accept()
dispatcher.close()
dispatcher_with_send
file_dispatcher
file_wrapper
- 17.6.1. asyncore Example basic HTTP client
- 17.6.2. asyncore Example basic echo server
- 17.7.
asynchat
— Asynchronous socket command/response handlerasync_chat
async_chat.close_when_done()
async_chat.collect_incoming_data()
async_chat.discard_buffers()
async_chat.found_terminator()
async_chat.get_terminator()
async_chat.push()
async_chat.push_with_producer()
async_chat.set_terminator()
- 17.7.1. asynchat - Auxiliary Classes
- 17.7.2. asynchat Example