What is the function of SOCK_STREAM?

Shashank Pulijala picture Shashank Pulijala · Mar 1, 2016 · Viewed 23.4k times · Source

I am learning about sockets in Python and came up with

variable = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

I understood the function of this socket.socket and socket.AF_INET but I am curious about socket.SOCK_STREAM. What is its function?

Answer

freakish picture freakish · Mar 1, 2016

SOCK_STREAM means that it is a TCP socket.

SOCK_DGRAM means that it is a UDP socket.

These are used 99% of the time. There are other possibilities as well, see https://docs.python.org/2/library/socket.html#socket.SOCK_STREAM (you will have to google for the meaning of each one).