monk3ybutts
YaBB Newbies
Offline
Posts: 39
getting data via http problem
Sep 19th , 2005, 5:05pm
hi i'm trying to intergrate processing with a web database, there's system set up that i can get the variable info, but it gets it the first time fine, but i get null everytime i try to read for more data (but that's obvious because it gets the buffer data) so i set up only get data when there is data, and if i keep sending to the server commands to get the data, sometimes the data coming back varies in sizes when it shouldn't. like the string i ask it to read sometimes grow or shrink signifigantly. this is making it very hard to use that data in processing. i'm having to split the string into an array to get the right data, but it's hard to know where the data is when the data changes in size and when it splits i can't seem to find the data at the right place in the array. but that's besides the point, the most important part is when the data changes, like new info is added, it crashes the program. this is the error java.net.SocketException: Software caused connection abort: socket write error at java.net.SocketOutputStream.socketWrite0(Native Method) i can't seem to get around this, happens everytime, i think the server is rejecting my http request when there's new buffer info because it thinks i'm spamming the server so it closes the connection, is there a way around? i need to get up to the second updated info from the server. here's the rest of my code import processing.net.*; String [] b; Client client; Client iclient; String newByte; void setup() { size(200, 200); noStroke(); // Open a TCP socket to the host: client = new Client(this, "localserver ", 80); iclient = new Client(this, "localserver ", 80); // Print the IP address of the host: println(client.ip()); // Send the HTTP GET request: client.write("GET /jay/master.cgi?past=1d HTTP/1.1\n"); client.write("HOST: localserver \n\n"); iclient.write("GET /jay/active_member.cgi HTTP/1.1\n"); iclient.write("HOST: localserver \n\n"); framerate(1); } void draw() { background(0); // Print the results of the GET: if (client.available() > 0) { String inByte= client.readString(); // print((char)inByte); //char data[] = char(inByte); String c[] = split(inByte); //String h []= loadStrixngs(c); //String n = c // b = split(c, RETURN); // println(c.length); client.clear(); } //if(iclient.available()>0){ try{ newByte = iclient.readString(); } catch(Exception e){ println("oops"); } // //if(newByte != null){ try{ //b = split(newByte); } catch(Exception e){ } //for(int i=0; i<20; i++){ println(newByte); // } try{ if(int(b[b.length-1]) != 0){ // println(b[b.length-1]); } } catch(Exception e){ } // } // } //iclient.clear(); } void keyPressed(){ try{ iclient.write("GET active_member.cgi HTTP/1.1\n"); iclient.write("HOST: localserver \n\n"); } catch(Exception e){ println("oops"); } }