FAQ
Cover
This is the archive Discourse for the Processing (ALPHA) software.
Please visit the new Processing forum for current information.

   Processing 1.0 _ALPHA_
   Programming Questions & Help
   Syntax
(Moderators: fry, REAS)
   Net methods.
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: Net methods.  (Read 287 times)
JohnG

WWW
Net methods.
« on: Oct 7th, 2003, 10:02pm »

I'm trying to get an applet to connect to a webserver at oen point to send/recieve a high score list (just as a test)
 
Trying to connect to a webserver, it connects, can netWrite(...) but refuses to read any data.
 
I used netcat to listen on a port on a remote machine, and told a local program to connect to that port on that machien and send "GET /index.html HTTP/1.0\n\n", to pretent to be a browser. It sent this data fine.
 
However, netEvent never got called on the client when I was typing pages of rubbish into the other end. Even closing the "server" down didn't register on the client end with anything in the text-ouput area.
 
Using another instance of processing, and the supplised examples, it seems to work fine.
 
Now, if it were using UDP instead of TCP I'd expect not to recieve any data on the other end, so I assume it's not that. I've also tried using processing as a server and telnetted in to see the data being streamed in.
 
Is there some special code sequence that needs to be returned before processing will read it?
 
I know that for an applet the sandbox only allows connections back to the originating server, but running locally it sould be able to connect elsewhere, and does without complaint.
 
 
Below is what I'd expect to use to simply get the frontpage for proce55ing.net. (Works telnetting directly)
 
Code:

color x;
 
void setup()  
{
  x=color(0,0,0);
  size(200,200);  
  beginNet("proce55ing.net", 80);  
  netWrite("GET /index.html HTTP/1.1\nHost: proce55ing.net\nConnection: close\n\n");
}  
 
void loop()  
{  
  background(x);
}  
 
void netEvent()  
{  
  x=color(255,255,255);
  println(net);
}  
 
fry


WWW
Re: Net methods.
« Reply #1 on: Oct 7th, 2003, 10:10pm »

the net methods are a bit broken as of now. you're better off just using the regular java.net.* stuff (tutorials prolly easily available).  
 
the net code is currently sending unicode data, which is useful for web servers and such, since they'll all be straight ascii, or utf8. thus the garbage
 
JohnG

WWW
Re: Net methods.
« Reply #2 on: Oct 7th, 2003, 10:28pm »

Thanks for the quick reply.
 
I'll go hunting through the Java books I have to get some simple net stuff.
 
fry


WWW
Re: Net methods.
« Reply #3 on: Oct 8th, 2003, 4:16pm »

i recommend the "java tutorial" (from sun) which is all online (and should have some net code), and the "java examples in a nutshell" book (from o'reilly) which has at least the code online for simple net clients and servers. both are great references in general.
 
senior

89237688923768 WWW
Re: Net methods.
« Reply #4 on: Oct 10th, 2003, 6:25pm »

Will the fixed Net code be rewritten using the new non-blocking sockets available in java 1.4? I think some of the freezing that the current system causes may be due to the current, crappy java sockets. (this said by the guy who's never seen the p5 source!)
 
fry


WWW
Re: Net methods.
« Reply #5 on: Oct 14th, 2003, 10:24pm »

we won't use the non-blocking i/o initially, since we're trying to target 1.1 platforms for exported things. however, we'll prolly have a second version that uses the fancy i/o, or maybe someone will contribute a .class that could be included with projects that want to use the fancy i/o.
 
Pages: 1 

« Previous topic | Next topic »