So I am trying to make a server program that will call the client program. The server client work fine if I call them myself from the command line but the connection is refused when the server calls it. Why is this not working?
This is the server code:
import socket,os s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) try: os.remove("/tmp/SocketTest") except OSError: pass s.bind("/tmp/SocketTest") os.system("python compute.py")#compute is the client #execfile('compute.py') s.listen(1) conn, addr = s.accept() while 1: data = conn.recv(1024) if not data: break conn.send(data) conn.close() This is the client code:
import socket s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) s.connect("/tmp/SocketTest") s.send('Hello, world \n') s.send('its a mighty fine day') data = s.recv(1024) s.close() print 'Received', repr(data)