import processing.core.PApplet; import processing.core.PFont; import processing.net.Client; import processing.net.Server; import processing.serial.Serial; public class SensorServer extends PApplet { Server myServer; int endOfMessageChar = 10; int socketPort = 9002; static public void main(String _args[]) { PApplet.main(new String[] { "SensorServer" }); } public void setup() { size(256, 256); // Stage size noStroke(); // No border on the next thing drawn myServer = new Server(this, socketPort); println("Starting a server at port " + socketPort); PFont myFont = createFont("Arial", 18); textFont(myFont); } public void draw(){ Client myClient = myServer.available(); if (myClient != null){ String _whatClientSaid = myClient.readStringUntil(endOfMessageChar); if (_whatClientSaid != null){ println("Client said: " + _whatClientSaid); myServer.write("They said " + _whatClientSaid); } } } public void serverEvent(Server someServer, Client _newClient) { println("We have a new client: " + _newClient.ip()); } }