Here's an example of opening and reading data from a TCP socket. Is there a way to create a UDP socket as well?
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