import socket import sys import array skname = sys.argv[1] sk = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) sk.connect(skname) data, anc, _flags, _addr = sk.recvmsg(100, 100) print(data.decode()) _level, _type, fdarr = anc[0] arr = array.array('i') arr.frombytes(fdarr) f = open(arr[0]) print(next(f)) input('reply?') protos = open('/etc/protocols') sk.sendmsg([b'hello!'], [(socket.SOL_SOCKET, socket.SCM_RIGHTS, array.array('i', [protos.fileno()]))], ) sk.close()