I was wondering if anyone had suggestions/examples of connecting to Python via a pipe? I’ve been running the demo, and creating a named pipe (which shows up under /tmp/ as two files, pipe_out and pipe_in). I’ve also tried to send to an existing pipe. But so far no luck. I’ve also tried TCP sockets, although that doesn’t seem like what I really want as this is process to process, and on the same machine.
When I create the server in python, and then try to connect from the JUCE demo, the demo tells me:
Connection #1 - connection started
Connection #1 - connection lost
I’m on OSX lion, and currently trying this python code:
import socket import sys import os server_address = '/tmp/mypipe' # 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) else: print >>sys.stderr, 'no more data from', client_address break finally: # Clean up the connection connection.close()