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.
Page Index Toggle Pages: 1
http request (Read 811 times)
http request
Jan 25th, 2010, 4:51pm
 
Im trying to find a way to have processing send a single repeatable http request i have tried using processing.net.* but when it will continue to call my perl script causing it to loop, i have to use the noLoop() or webrequest.stop() and then the function is not repeatable like in a if statement.

in this case i need to be capable  of  pressing x and having the web request go out every time x is pressed.

thanks for any help or info on this


Code:
import processing.net.*;
int msg = 8;
Client webrequest;
int data;


void setup() {
 size(200, 200);
 background(50);
 fill(200);

 webrequest = new Client(this, " 127.0.0.1", 80);


}
void draw() {
if (key == 'x') {
 webrequest.write("GET /cgi-bin/cgi.pl?"+ msg +" HTTP/1.1\n");
 webrequest.write("Host: Processing\n\n");

noLoop();

}
}
Re: http request
Reply #1 - Jan 25th, 2010, 5:49pm
 
Put the code that's doing the web request in keyPressed(), perhaps?
Re: http request
Reply #2 - Jan 25th, 2010, 7:59pm
 
thanks i removed void draw() for void keyPressed() and works great now!  Cheesy
Page Index Toggle Pages: 1