Hi all,
I've written application based on Client class, which opens a client connections, sends a query to a server and gets an answer from it.
How can I speed up this? I've been told that this comes from the JVM itself. Is it possible?
Maybe this is a too vague question, but I need to speed up the socket reading in my sketch. Is it possible to get faster answers? The fact is that the webserver answers quite fast (in less than 1 second), while this simple sketch takes longer (around 5 seconds) to get an string with an answer.
I've written application based on Client class, which opens a client connections, sends a query to a server and gets an answer from it.
Copy code
- /**
* HTTP Client.
*
* Starts a network client that connects to a server on port 80,
* sends an HTTP 1.0 GET request, and prints the results.
*
* Note that this code is not necessary for simple HTTP GET request:
* Simply calling loadStrings("http://www.processing.org") would do
* the same thing as (and more efficiently than) this example.
* This example is for people who might want to do something more
* complicated later.
*/
import processing.net.*;
// import processing.xml.*;
Client c;
String data;
void setup() {
size(200, 200);
background(50);
fill(200);
c = new Client(this, "192.168.1.41", 8081); // Connect to server on port 8081
}
void draw() {
if (c.available() > 0) { // If there's incoming data from the client...
data = c.readString(); // ...then grab it and print it
println(data);
}
}
How can I speed up this? I've been told that this comes from the JVM itself. Is it possible?
Maybe this is a too vague question, but I need to speed up the socket reading in my sketch. Is it possible to get faster answers? The fact is that the webserver answers quite fast (in less than 1 second), while this simple sketch takes longer (around 5 seconds) to get an string with an answer.
Thanks in advance!
SAM