Подробная информация о работе с сокетами в Python
https://pymotw.com/2/socket/uds.html
Вы можете общаться с сокетами, используя netcat-openbsd
или socat
nc -U <path_to_socket_file>
socat - UNIX-CONNECT:<path_to_socket_file>
источник для второй части: https://unix.stackexchange.com/questions/26715/how-can-i-communicate-with-a-unix-domain-socket-via-the-shell-on-debian-squeeze
ОБНОВЛЕНИЕ: вот пример сервера сокетов, взятого из первой ссылки
import socket
import sys
import os
server_address = './uds_socket'
# Make sure the socket does not already exist
try:
os.unlink(server_address)
except OSError:
if os.path.exists(server_address):
raise
# Create a UDS socket
sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
# Bind the socket to the port
print >>sys.stderr, 'starting up on %s' % server_address
sock.bind(server_address)
# Listen for incoming connections
sock.listen(1)
while True:
# Wait for a connection
print >>sys.stderr, 'waiting for a connection'
connection, client_address = sock.accept()
try:
print >>sys.stderr, 'connection from', client_address
# Receive the data in small chunks and retransmit it
while True:
data = connection.recv(16)
print >>sys.stderr, 'received "%s"' % data
if data:
print >>sys.stderr, 'sending data back to the client'
connection.sendall(data.upper())
else:
print >>sys.stderr, 'no more data from', client_address
break
finally:
# Clean up the connection
connection.close()
сохраните это в файл с именем sock.py и запустите
~/Development/temp ᐅ python sock.py
starting up on ./uds_socket
waiting for a connection
, затем подключитесь, используя socat
~/Development/temp ᐅ socat - UNIX-CONNECT:uds_socket
hello
HELLO
напишите что-нибудь -и вы получите то же самое, но в верхнем регистре в качестве ответа.