Here's a simple TCP client in Processing:


/**
 * Simple net Client. 
 * 
 * Starts a network client that connects to a server on port 8080,
 * sends any keystrokes pressed. 
 */


import processing.net.*;

Client myClient;                   // instance of the net Client
String data;                       // string to hold incoming data
String ipAddress = "127.0.0.1";    // address of the server goes here

void setup() {
  // establish the background and foreground:
  size(200, 200);      
  background(50);
  fill(200);
   // Connect to server on port 8080
  myClient = new Client(this, ipAddress, 8080);
}

void draw() {
  // If there's incoming data from the client:
  if (myClient.available() > 0) { 
    // get the data:
    data = myClient.readString(); 
    println(data);
  }

 if (keyPressed) {
   // send out anything that's typed:
  myClient.write(key); 
 }
}