Cheatsheet for Python networking, organized into different sections and tables for various commands and concepts related to networking in Python:
-
Socket Programming
Command Description socket.socket()
Create a new socket socket.bind()
Bind the socket to an address and port socket.listen()
Listen for incoming connections socket.accept()
Accept an incoming connection socket.connect()
Connect to a remote address and port socket.recv()
Receive data from the socket socket.send()
Send data through the socket socket.close()
Close the socket socket.gethostname()
Get the hostname of the local machine socket.gethostbyname()
Get the IP address of a hostname socket.getsockname()
Get the socket's own address -
UDP (User Datagram Protocol)
Command Description socket.SOCK_DGRAM
Create a UDP socket socket.sendto()
Send data over UDP socket.recvfrom()
Receive data over UDP -
TCP (Transmission Control Protocol)
Command Description socket.SOCK_STREAM
Create a TCP socket socket.getsockopt()
Get socket options socket.setsockopt()
Set socket options socket.gettimeout()
Get the socket's timeout socket.settimeout()
Set the socket's timeout socket.setblocking()
Set whether the socket is blocking socket.makefile()
Create a file-like object from the socket -
Networking Libraries
Library Description socket
Basic networking functionality http.client
HTTP client library http.server
HTTP server library urllib.request
URL handling and retrieval urllib.parse
URL parsing and manipulation requests
HTTP library for making requests -
Networking Protocols
Protocol Description HTTP
Hypertext Transfer Protocol HTTPS
Secure HTTP FTP
File Transfer Protocol SMTP
Simple Mail Transfer Protocol POP3
Post Office Protocol version 3 IMAP
Internet Message Access Protocol -
Security and Encryption
Command Description ssl
Secure Sockets Layer hashlib
Cryptographic hashing functions
Remember to import the necessary libraries/modules before using the commands. This cheatsheet provides a comprehensive overview of Python networking, covering a wide range of concepts and commands. Always refer to the official Python documentation or relevant resources for detailed usage and examples.