Quantcast
Channel: Processing Forum
Viewing all articles
Browse latest Browse all 1768

Howto speed up a Client Application?

$
0
0
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.

Copy code
  1. /**
     * 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);
      }
    }
The application runs good but there are some issues regarding to its processing speed. It takes 5 s to get an answer from the webserver, while it should be possible to get it in less than 1 s by other means.

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

Viewing all articles
Browse latest Browse all 1768

Trending Articles