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 › Network Library/clientEvent abnormally triggered
Page Index Toggle Pages: 1
Network Library/clientEvent abnormally triggered (Read 678 times)
Network Library/clientEvent abnormally triggered
Oct 25th, 2009, 8:01pm
 
HI,

this is a copy of a bug report that I have posted.

The problem I encounter with this procedure is that it is triggered regularly, even when no data is available.

I have made two tests : one with Roborealm telnet server and one with a SSH server.

--------------------- General Local System Info

Processing 1.0.7
Windows XP Pro SP3
Toshiba T2300

-------------------- Bug description

When using the clientEvent procedure from the network library, the
procedure gets triggered all the time even when no data is coming from the server.

----------------------- Test code and output

The following program starts a client to the Roborealm telnet server and writes a command. The clientEvent procedure is supposed to get data from server when available. As the output shows, clientEvent is triggered regularly without any data available.

--------------------------------- CODE

import processing.net.*;
Client myClient;
int dataIn;
byte[] byteBuffer = new byte[128];

// The program tries to talk to RoboRealm telnet interface on port 6060.

void setup() {
println("Starting");
myClient = new Client(this, "127.0.0.1", 6060);
println("Querying");
myClient.write("<request><get_all_variables></get_all_variables></request>");
println("Waiting");
}

// Empty draw loop
void draw() {
}

// Client Event gets data from server and prints it or says "no data available"

void clientEvent(Client myClient) {
print("Server Says: ");
if (myClient.available() > 0) {
int byteCount = myClient.readBytes(byteBuffer);
if (byteCount > 0 ) {
// Convert the byte array to a String and print it
String myString = new String(byteBuffer);
println(myString);
}
}
else {
println("No Data");
}
}


------------------------ OUTPUT




Starting
Server Says: No Data
Querying
Waiting
Server Says: No Data
Server Says: No Data
Server Says: No Data
Server Says: No Data
Server Says: No Data
Server Says: No Data
Server Says: No Data
Server Says: No Data
Server Says:
<response><POWER_LIFE_TIME>-1</POWER_LIFE_TIME><FPS></FPS><IMAGE_TIME>0.000000</
IMAGE_TIME><IMAGE_WIDTH>640</IMAGE_WIDTH><SERVO_
Server Says:
VALUE>0</SERVO_VALUE><IMAGE_HEIGHT>480</IMAGE_HEIGHT><POWER_LIFE_PERCENT>100</PO
WER_LIFE_PERCENT><PROCESS_TIME>31</PROCESS_TIME>
Server Says:
<MOVEMENT_PERCENT>0</MOVEMENT_PERCENT><IMAGE_COUNT>164</IMAGE_COUNT><POWER_CHARG
E>HIGH</POWER_CHARGE><IMAGE_PROCESSED>164</IMAGE
Server Says:
_PROCESSED><MOVEMENT_PIXELS>0</MOVEMENT_PIXELS><POWER_DEVICE>AC</POWER_DEVICE></
response>OWER_CHARGE><IMAGE_PROCESSED>164</IMAGE
Server Says: No Data
Server Says: No Data
Server Says: No Data
Server Says: No Data
Server Says: No Data
Server Says: No Data
Server Says: No Data


I don't know if someone else has the same behaviour or if there is a known workaround.

I know that the CPU time consumed is rather minimal but I'd like to understand what triggers the procedure.

Thanks.
Page Index Toggle Pages: 1