IAT267 Broadcast Server Example.docx

3 Pages
Unlock Document

Interactive Arts & Tech
IAT 267
Helmine Serban

Broadcast Server Server Code // Import the net libraries import processing.net.*; // Declare a server Server server; PFont f; int data = 0; void setup() { size(200,200); // Create the Server on port 5204 server = new Server(this, 5204); f = createFont("Arial",20,true); } void draw() { background(255); // Display data textFont(f); textAlign(CENTER); fill(0); text(data,width/2,height/2); // Broadcast data (the number is continuously sent to all clients because write() is called every cycle through draw()) server.write(data); // Arbitrarily changing the value of data randomly data = (data + int(random( -2,4))) % 256; } // The serverEvent function is called whenever a new client connects. void serverEvent(Server server, Client client) { println(" A new client has connected: "+ client.ip()); } Client1 Code // Import the net libraries import processing.net.*; // Declare a client
More Less

Related notes for IAT 267

Log In


Join OneClass

Access over 10 million pages of study
documents for 1.3 million courses.

Sign up

Join to view


By registering, I agree to the Terms and Privacy Policies
Already have an account?
Just a few more details

So we can recommend you notes for your school.

Reset Password

Please enter below the email address you registered with and we will send you a link to reset your password.

Add your courses

Get notes from the top students in your class.