FAQ
 
 
Cover  \ Exhibition  \ Learning  \ Reference  \ Download  \ Discourse   
      Language \ Environment \ Libraries \ Comparison
 
   
   
Back  
   
  Reference for Processing (BETA) version 91+. If you have a previous version, use the reference included with your software. If you see any errors or have any comments, let us know.  
Name  

Server

   
Examples  
import processing.net.*; 
Server myServer; 
int val = 0; 
 
void setup() { 
  size(200, 200); 
  // Starts a myServer on port 5204 
  myServer = new Server(this, 5204); 
} 
 
void draw() { 
  val = (val + 1)%255; 
  background(val); 
  myServer.write(val); 
} 
 

Description   A server sends and receives data to and from its associated clients (other programs connected to it). When a server is started, it begins listening for connections on the port specified by the port parameter. Computers have many ports for transferring data and some are commonly used so be sure to not select one of these. For example, web servers usually use port 80 and POP mail uses port 110.
   
Methods  
write()
  Writes data to all connected clients

available()
  Returns the next client in line with a new message

stop()
  Disconnects all clients and stops the server

disconnect()
  Disconnect a particular client

   
   
Constructors  
Server(parent, port)
   
Parameters  
parent   PApplet: typically use "this"

port   int: port used to transfer data

   
Usage   Application
   
 
 






   
 
Updated: Fri Jul 15 16:41:09 PDT 2005
 
 








Creative Commons License
 
  Processing is an open project initiated by Ben Fry and Casey Reas  
  © Info  
nt> and Casey Reas     © Info   ource.org/cc/Notice" /> -->     Processing is an open project initiated by Ben Fry and Casey Reas     © Info   native file format.