Here's detailed info on working with sockets in Python
https://pymotw.com/2/socket/uds.html
You can communicate with sockets using netcat-openbsd
or socat
nc -U <path_to_socket_file>
socat - UNIX-CONNECT:<path_to_socket_file>
source for the second part: https://unix.stackexchange.com/questions/26715/how-can-i-communicate-with-a-unix-domain-socket-via-the-shell-on-debian-squeeze
UPDATE: here's an example of a socket server taken from the first link
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()
save this into a file called sock.py and run
~/Development/temp ᐅ python sock.py
starting up on ./uds_socket
waiting for a connection
then connect using socat
~/Development/temp ᐅ socat - UNIX-CONNECT:uds_socket
hello
HELLO
write something - and you'll receive the same thing but in uppercase as a reply.