Reference+
Class Name
Server
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.
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); }
Constructors
Server(parent, port)
Server(parent, port, host)
Parameters
parent
(PApplet)
typically use "this"port
(int)
port used to transfer dataparent
(PApplet)
typically use "this"port
(int)
port used to transfer datahost
(String)
when multiple NICs are in use, the ip (or name) to bind from
Methods
disconnect()
Disconnect a particular clientactive()
Return true if this server is still activeavailable()
Returns the next client in line with a new messagestop()
Disconnects all clients and stops the serverwrite()
Writes data to all connected clients
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.