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.

Class

Client

Name

write()

Examples
// Creates a client that sends input to a server

import processing.net.*; 
Client myClient; 
int clicks;

void setup() { 
  // Connect to the local machine at port 10002.
  // This example will not run if you haven't
  // previously started a server on this port.
  myClient = new Client(this, "127.0.0.1", 10002); 
  // Say hello
  myClient.write("Hi there");
} 

void mouseReleased() {
  // Count the number of mouse clicks:
  clicks++;
  // Tell the server:
  myClient.write("Mouse pressed " + clicks + " times.\n");
}

void draw() { 
  // Change the background if the mouse is pressed
  if (mousePressed) {
    background(255);
  } else {
    background(0);
  }
} 

Description Writes data to a server specified when constructing the client, or writes data to the specific client obtained from the Server available() method.
Syntax
client.write(data)
Parameters
client Client: any variable of type Client
data String, byte[], or int: data to write
Returnsvoid
Updated on January 1, 2021 03:38:10am EST