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

Re : Howto speed up a Client Application?

$
0
0
Thanks for your answer, PhiLho!
The webserver and my client are connected in a same WIRELESS LAN, so there is no suitable reason for this delay. Indeed, I can appreciate this delay.

My code is something like the sketch I have posted before with some small additions:

  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.*;
    
    Client c;
    String data;
    
    void setup() {
      size(200, 200);
      background(50);
      fill(200);
      c = new Client(this, "192.168.1.43", 8081); // Connect to server on port 8081
      //  c.write("GET / HTTP/1.1 /cgi-bin/getPoolmacParams \r\n");
      //  c.write("Host: 192.168.5.9:8081\r\n");
    
      c.write("GET /cgi-bin/getPoolmacParams HTTP/1.1\r\n");
      c.write("Host: 192.168.1.43:8081\r\n");
      c.write("User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:20.0) Gecko/20100101 Firefox/20.0\r\n");
      c.write("Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\n");
      c.write("Accept-Language: ca,en-us;q=0.7,en;q=0.3\r\n");
      c.write("Accept-Encoding: gzip, deflate\r\n");
      c.write("DNT: 1\r\n");
      c.write("Authorization: Basic ZmlkZXM6NDMyMQ==\r\n");
      c.write("Connection: keep-alive\r\n");
      c.write("Cache-Control: max-age=0\r\n");
      c.write("\r\n");
    }
    
    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 main difference are those Strings sent after the connection and just before data is being received. I've just catcht through Wireshark the strings sent by a web browser in order to make the same job in Processing.


SAM

Viewing all articles
Browse latest Browse all 1768

Trending Articles