Skip to content

Latest commit

 

History

History
18 lines (12 loc) · 801 Bytes

File metadata and controls

18 lines (12 loc) · 801 Bytes

Unix domain sockets are a common way for processes on the same machine to communicate with each other. They are represented as files in the filesystem. While you can create them programmatically, you can also create them quickly from the command line for testing or scripting purposes.

One of the easiest ways to create a Unix socket is with the socat utility. The following command will create a socket and listen for connections on it:

socat UNIX-LISTEN:/tmp/mysocket.sock -

Alternatively, you can use a short Python script to create a socket:

import socket
s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
s.bind('/tmp/mysocket.sock')

This will create a socket file at the specified path, which can then be used by other processes to connect and communicate.