topical media & game development

talk show tell print

graphic-processing-learning-19-example-19-4-example-19-4.pde / pde



  // Learning Processing
  // Daniel Shiffman
  // http://www.learningprocessing.com
  
  // Example 19-4: Client reading values as background color
  
  // Import the net libraries
  import processing.net.*;
  // Declare a client
  Client client;
  // The data we will read from the server
  int data;
  
  void setup() {
    size(200,200);
    // Create the Client
    client = new Client(this,"127.0.0.1", 5204);
  }
  
  void draw() {
    
    // Read data
    if (client.available() > 0) {
      data = client.read(); 
    }
    
    // The incoming data is used to color the background.
    background(data); 
  }
  


(C) Æliens 20/2/2008

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.