Hi, I have an inetd service on freebsd that calls a program (daemon.py) with which I want the remote user to communicate. I can call daemon.py from the command line on the host machine and it works fine.
What I don't understand is how to make my remote client script actually communicate. If I'm understanding correctly, the code below just takes a message and sends it to inetd and writes the stdout from the process to the client. How can I modify the code to send a response back? Here's the outline of what I want to do: (1) client sends the message to the server (client -> inetd -> daemon.py), (2) client receives output back from the server, (3) client user responds to a question from the remote process (4) client continues to receive output back. where 2-3-4 happen as needed by the remote process. Cries out for a while loop doesn't it? I just don't know what to put in it. Currently I just have steps 1 and 2 working. Client sends one message and gets all output back. If server asks a question, processes deadlock with server waiting and client unable to respond. thanks, --Tim Arnold # imports, constants set #def line_buffer(sock): # code to yield the string response in # blocks of 1024 bytes def client(ip,port,message): sock = socket.socket(socket.AF_INET,socket.SOCK_STREAM) sock.connect((ip,port)) sock.send(message) for line in line_buffer(sock): print line sock.close() if __name__ == '__main__': message = ' '.join(sys.argv[1:]) ) print 'working... %s %s' % (SERVER_IP,SERVER_PORT) client(SERVER_IP,SERVER_PORT,message) print 'done.' -- http://mail.python.org/mailman/listinfo/python-list