Skip to content

Python Socket Programming

Cameron Auler edited this page Oct 7, 2022 · 7 revisions

Client-server Architecture

The server has a particular function and usually does not initiate the connection. The server stores the data or service that a client is trying to access, but it is the responsibility of the client to initiate the connection. Think of the server as a room. Each port is a door to that room.

Sockets

Sockets are communication endpoints. Python requires a socket type and a protocol type in order to initialize an open port(socket).

Socket Type Description
socket.AF_INET Internet socket for IPv4
socket.AF_INET6 Internet socket for IPv6
socket.AF_BLUETOOTH Bluetooth socket
Protocol Type Description
SOCK_STREAM TCP - connection-based socket.
SOCK_DGRAM UPD - unverified datagram socket.

Resources

Clone this wiki locally