I’ve just come across sockets and the python socket module (and am quite new to python!). What are AF_UNIX and SOCK_STREAM variables (?) used for? I’ve found them in a bit of code (in a method of a class):
self._sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
What is this assignment doing?
AF_UNIXis configuring the socket as a unix socket. A unix socket is a mechanism for two processes on the same system to communicate with each other. If it were set toAF_INETit would be a TCP/IP socket.SOCK_STREAMis configuring how processes should talk over the socket, in this case the processes exchange a byte stream. See here.You should also check out the python socket docs, as they’re pretty good.