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 interfaceerrorherrorgaierrortimeoutAF_UNIXAF_INETAF_INET6SOCK_STREAMSOCK_DGRAMSOCK_RAWSOCK_RDMSOCK_SEQPACKETSOMAXCONNhas_ipv6create_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.familysocket.typesocket.proto
- 17.2.2. Example
- 17.3.
ssl— TLS/SSL wrapper for socket objects- 17.3.1. Functions, Constants, and Exceptions
SSLErrorSSLZeroReturnErrorSSLWantReadErrorSSLWantWriteErrorSSLSyscallErrorSSLEOFErrorCertificateError- 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_NONECERT_OPTIONALCERT_REQUIREDVERIFY_DEFAULTVERIFY_CRL_CHECK_LEAFVERIFY_CRL_CHECK_CHAINVERIFY_X509_STRICTVERIFY_X509_TRUSTED_FIRSTPROTOCOL_TLSPROTOCOL_SSLv23PROTOCOL_SSLv2PROTOCOL_SSLv3PROTOCOL_TLSv1PROTOCOL_TLSv1_1PROTOCOL_TLSv1_2OP_ALLOP_NO_SSLv2OP_NO_SSLv3OP_NO_TLSv1OP_NO_TLSv1_1OP_NO_TLSv1_2OP_NO_TLSv1_3OP_CIPHER_SERVER_PREFERENCEOP_SINGLE_DH_USEOP_SINGLE_ECDH_USEOP_ENABLE_MIDDLEBOX_COMPATOP_NO_COMPRESSIONHAS_ALPNHAS_ECDHHAS_SNIHAS_NPNHAS_TLSv1_3CHANNEL_BINDING_TYPESOPENSSL_VERSIONOPENSSL_VERSION_INFOOPENSSL_VERSION_NUMBERALERT_DESCRIPTION_HANDSHAKE_FAILUREALERT_DESCRIPTION_INTERNAL_ERRORPurpose.SERVER_AUTHPurpose.CLIENT_AUTH
- 17.3.2. SSL Sockets
- 17.3.3. SSL Contexts
SSLContextSSLContext.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_hostnameSSLContext.optionsSSLContext.protocolSSLContext.verify_flagsSSLContext.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()dispatcherdispatcher.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_sendfile_dispatcherfile_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_chatasync_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
