This reference is for Processing 3.0+. If you have a previous version, use the reference included with your software in the Help menu. If you see any errors or have suggestions, please let us know. If you prefer a more technical reference, visit the Processing Core Javadoc and Libraries Javadoc.



// Bug note: stopping the server produces an unrecoverable error:
// " Socket closed
//  at Method)"

int port = 10002;
boolean myServerRunning;
Server myServer;

void setup() {
  size(400, 400);
  myServerRunning = false;
  println("Server Running:" + "t" + myServerRunning);

void draw() {
  // Nothing happening here, everything happens in mousePressed()

void mousePressed() {
  // If the mouse clicked the myServer changes status
  if (myServerRunning) {
    // N.B. This produces an error which kills the sketch.
    myServerRunning = false;
    myServer = null;
  else {
    myServer = new Server(this, port); // Starts a server on port 10002
    myServerRunning = true;
  println("Server Status:" + "t" + myServerRunning);

Description Returns the IP address of the server. This method is static, so it's run with the code Server.ip(), rather can calling the ip() method of an object created from the Server class.

Note that the address may be part of a private network and only accessible to other machines within the same network. In other cases, a publicly accessible address may be returned (though additional router configuration work may be needed to route connections to your machine). In either case, it depends on how the network you connect to is configured and (more rarely) on the network settings of your machine.
Updated on June 6, 2020 10:05:51pm EDT