sending data to another process's input stream?

Donn Cave donn at u.washington.edu
Fri May 21 13:24:09 EDT 1999


"Joseph J. Strout" <joe at strout.net> writes:
|At 4:43 PM -0700 05/20/99, Paul Prescod wrote:
|>You can use os.popen2 or something like it. But the trick is that the app
|>that calls os.popen can't close or else it loses the file handle. So you
|>need a long running Python app.

| Got it.  Long-running Python app acts as a wrapper around the C++ program,
| and communicates with the short-lived Python CGIs via sockets -- which
| avoids having to put socket yuckiness into my C++ code.

Along with the socket yuckiness (sockaddr structs, network byte order,
stuff that Python does for you), you also get some functionality.
With its own bound socket, the C++ program is equipped to be a real
server, with a separate connection for each client, simultaneously
if you want.  And look out for buffering - cout will buffer output
to the pipe, so there's a potential for deadlock due to output that
has programmatically been "written" but is only buffered in the process.

	Donn Cave, University Computing Services, University of Washington
	donn at u.washington.edu




More information about the Python-list mailing list