serverEvent()\ net \ Language (API) \ Processing 1.0
Author: Casey Reas & Ben Fry
Description: Processing is an electronic sketchbook for developing ideas. It is a context for learning fundamentals of computer programming within the context of the electronic arts.
Keywords: Processing, Processing, Interactive Media, Electronic Arts, Programming, Java, Ben Fry, Casey Reas

Reference for Processing version 1.1+. If you have a previous version, use the reference included with your software. If you see any errors or have suggestions, »please let us know. If you prefer a more technical reference, visit the »Processing Javadoc.

Name | ### serverEvent()
Examples |
    // Example by Tom Igoe
    // Creates a server that prints new client's IP addresses.

    import processing.net.*;

    int port = 10002;
    Server myServer;

    void setup()
    {
      size(400, 400);
      background(0);
      myServer = new Server(this, port); // Starts a server on port 10002
    }

    void draw() {
      // Nothing happens here, everything happens inside ServerEvent()
    }

    // ServerEvent message is generated when a new client connects
    // to an existing server.
    void serverEvent(Server someServer, Client someClient) {
      println("We have a new client: " + someClient.ip());
    }
Description | The code inside serverEvent() is run when a new client connects to a server that has been created within the program.
Syntax |
    void serverEvent(server, client) {
      statements
    }
Parameters |
server | Server: server the client is connecting to
client | Client: client connecting to the server
statements | any valid statements
Usage | Application
Related | Server

Updated on June 14, 2010 12:05:29pm EDT