Here's an example of opening and reading data from a TCP socket. Is there a a popen() call or equivalent that can start a child process and read its output?
void setup() {
c = new Client(this, "127.0.0.1", 12345); // Replace with your server's IP and port
}
void draw() {
if (c.available() > 0) {
input = c.readString();
http://www.processing.org/learning/libraries/sharedcanvasclient.html