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)
   Using net library in v74
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: Using net library in v74  (Read 1947 times)
reg


Using net library in v74
« on: Apr 18th, 2005, 2:01pm »

Hi All.
 
I've been playing with the net library in v68 and v74, and got simple examples and demos to run using both.  The v74 network support is much, much nicer ... well done guys ... because you can look in the java files and work out how to use it much more intuitively than v68.
 
OK enough platitudes, what's my question:  How do I get the client/server example in v74 to work robustly?  
 
On the SERVER:
 
The server code includes a dispose() call that shuts down the server on a mouse click, but still triggers an error:
 
Error inside Server.run()Error inside Server.run()
 
java.net.SocketException: socket closedjava.net.SocketException: socket closed
 
 at java.net.PlainSocketImpl.socketAccept(Native Method)
 
In fact the example doesn't even manage to call the "server stopped" console message as intended in the example code - this can be fixed by moving the "server.write(bgColor);" line within the example, so at least the code keeps running, but still generates an error from within libary code.
 
Ammendment to Example:
 
  if (serverRunning == true)
  {
    text("Server", 15, 60);
    text("sending", 15, 95);
    text("color " + bgColor, 15, 130);
     
    server.write(bgColor);  
  }
  else
  {
    text("server", 15, 60);
    text("stopped", 15, 95);
    text(millis(), 15, 120);
     
  }
 
On the CLIENT:
 
There is no code in the example given to disconnect / shut down the client.  Just closing the window causes the server to crash:
 
Error inside Client.write()Error inside Client.write()
 
java.net.SocketException: Connection reset by peer: socket write errorjava.net.SocketException: Connection reset by peer: socket write error
 
 at java.net.SocketOutputStream.socketWrite0(Native Method)
 
I tried to figure it out for myself by digging into the library files, found the dispose calls in the client code and used them to disconnect.  I added some code to call dispose() and to try to avoid doing it whilst still reading from the server.  But I still get errors from Client.run, which seems to still be running after I call client.dispose().
 
Asking to close link to server...
disconnecting server...
 
java.lang.NullPointerExceptionjava.lang.NullPointerException
 
 at processing.net.Client.run(Client.java:129)
 
This probably all comes down to threads, but dbeugging these is a bit beyond my java skills at the moment.  
 
So in summary:  how do I get the client/server examples of the net library in version 74 to allow disconnection / reconnection of clients, or shut down of the server without crashing both server and client?  And ideas, pointers to documentation that I've missed or creative suggestions appreiated ... I'd rather use the examples / libraries than embed/write my own java sockets into my P5 code.
 
VBR,
 
Reg
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
TomC

WWW
Re: Using net library in v74
« Reply #1 on: Apr 18th, 2005, 4:42pm »

Not familiar with the net stuff myself, but questions relating to versions 70+ should really be sent to the beta mailing list, or sent to the person who supplied you with it.
 
reg


Re: Using net library in v74
« Reply #2 on: Apr 18th, 2005, 7:46pm »

Ok, thx Tom, understood.  Having checked the status page about the Beta release dates, maybe things will be clearer very soon...
 
Pages: 1 

« Previous topic | Next topic »