Name

socket

Synopsis

socket(family,type)

Creates and returns a socket object with the given family and type. family is usually the constant attribute AF_INET of module socket, indicating you want a normal, Internet (i.e., TCP/IP) kind of socket. Depending on your platform, family may also be another constant attribute of module socket. For example, AF_UNIX, on Unix-like platforms only, indicates that you want a Unix-kind socket. This book does not cover sockets that are not of the Internet kind, since it focuses on cross-platform Python. type is one of a few constant attributes of module socket; generally, type is SOCK_STREAM to create a TCP (connection-based) socket, or SOCK_DGRAM to create a UDP (datagram-based) socket.

Get Python in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.