We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpOther Libraries › NET: Server Broadcasting (Public vs. Private)
Page Index Toggle Pages: 1
NET: Server Broadcasting (Public vs. Private) (Read 958 times)
NET: Server Broadcasting (Public vs. Private)
Mar 26th, 2010, 8:06pm
 
Hi,

I am working with the net libraries in processing and I am wondering if there is anyway of having a server communicate a message directly to one connected client instead of broadcasting to all connected clients via the write() function.

This is the code for my server:

Code:
import processing.net.*;

//// VARIABLES ////

// CREATE SERVER //
Server server;

String incomingMessage = "";

//// SETUP ////

void setup () {
size(400, 200);

// INITALIZE PUBLIC VARIABLES //

// SERVER //
server = new Server(this, 6262);
}

//// DRAW ////

void draw () {
background(255);

check4Client();
}

//// FUNCTIONS ////

void serverEvent (Server server, Client client) {
incomingMessage = "A new client has connected: " + client.ip();
}

void check4Client () {
// set client
Client client = server.available();
// Check if null
if (client != null) {
// Recieve message
incomingMessage = client.readStringUntil('*');
println("Client says: " + incomingMessage);
server.write(incomingMessage);
}
}
//End of Sketch


The server reads the string from a specified client:

  Client client = server.available();

but when The server sends a response I use the Write function which sends a return string to all clients.  This is annoying for many reasons.  clients receive strings of irrelevant information which slows down their sketch and strings can contain sensitive information.

Any help would be appreciated.

Thanks in advance
Re: NET: Server Broadcasting (Public vs. Private)
Reply #1 - Apr 5th, 2010, 7:37am
 
Oh! I'm interested in the following problem too!
Deos anybody have a solution for this issue?
Re: NET: Server Broadcasting (Public vs. Private)
Reply #2 - Apr 6th, 2010, 11:51pm
 
It's not a bug; it's a feature.
Page Index Toggle Pages: 1