I suggest you implement your own server in Processing and talk to it through the Arduino
check the following code:
import processing.net.*;
Server myServer;
void setup() {
size(200, 200);
// Starts a myServer on port 1234, change this to whatever suits you!
myServer = new Server(this, 1234);
}
void draw() {
// Get the next available client
Client thisClient = myServer.available();
// write the output of the client
if (thisClient !=null) {
String whatClientSaid = thisClient.readString();
if (whatClientSaid != null) {
println(thisClient.ip() + "t" + whatClientSaid);
}
}
}
and the Arduino code (for Ethernet example, easy to adopt):
#include <SPI.h>
#include <Ethernet.h>
// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = {
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192,168,1,177);
// Enter the IP address of the server you're connecting to:
IPAddress server(192,168,1,1);
// Initialize the Ethernet client library
// with the IP address and port of the server
EthernetClient client;
void setup() {
// start the Ethernet connection:
Ethernet.begin(mac, ip);
// start the serial library:
Serial.begin(9600);
// give the Ethernet shield a second to initialize:
delay(1000);
Serial.println("connecting...");
// if you get a connection, report back via serial:
if (client.connect(server, 1234)) {
Serial.println("connected");
}
else {
// if you didn't get a connection to the server:
Serial.println("connection failed");
}
}
void loop() {
//The following code will simply send characters for Terminal input to the server - use it as a test
while (Serial.available() > 0) {
char inChar = Serial.read();
if (client.connected()) {
client.print(inChar);
}
}
// if the server's disconnected, stop the client:
if (!client.connected()) {
Serial.println();
Serial.println("disconnecting.");
client.stop();
// do nothing:
while(true);
}
}