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.
IndexProgramming Questions & HelpOther Libraries › What can connect to Processing Servers
Page Index Toggle Pages: 1
What can connect to Processing Servers? (Read 1286 times)
What can connect to Processing Servers?
Apr 30th, 2007, 7:08pm
 
Are Processing Client objects the only thing that can connect to Processing Server objects? I'm trying to get a Python script to connect to a Server broadcasting on a local port, but the Server crashes as soon as I try to connect with a socket in the Python script. The Python script just complains about the connection being refused. I'm pretty clueless about networking, so, any thoughts?
Re: What can connect to Processing Servers?
Reply #1 - Apr 30th, 2007, 7:40pm
 
Anything should be able to conect, a socket is a socket is a socket.
Re: What can connect to Processing Servers?
Reply #2 - Apr 30th, 2007, 7:48pm
 
Yep, you are right. It's the problem that I saw mentioned elsewhere that if the client disconnects the server goes down. I modified my Python script to loop until it doesn't receive data any more and that worked great.

One thing to note: I wanted to send the position of the mouse in the Processing sketch to the Python script. But the Python socket reads strings, so it was necessary to send the coordinates as strings and then read 4 bytes at a time from the socket on the Python end. Hopefully this info will be helpful to other folks.
Re: What can connect to Processing Servers?
Reply #3 - May 6th, 2007, 9:15pm
 
How does your python script looping stop the server from crashing?

i notice that in version 0124 i get a java.net.SocketException when i stop the server itself (regardless of if it has any clients connected or not)

here's the error:
java.net.SocketException: Socket closed

at java.net.PlainSocketImpl.socketAccept(Native Method)

at java.net.PlainSocketImpl.accept(PlainSocketImpl.java:384)

at java.net.ServerSocket.implAccept(ServerSocket.java:450)

at java.net.ServerSocket.accept(ServerSocket.java:421)

at processing.net.Server.run(Server.java:158)

at java.lang.Thread.run(Thread.java:613)
Exception in thread "Thread-3" java.lang.RuntimeException: Error inside Server.run()

at processing.core.PApplet.die(PApplet.java:2336)

at processing.core.PApplet.die(PApplet.java:2354)

at processing.net.Server.errorMessage(Server.java:227)

at processing.net.Server.run(Server.java:174)

at java.lang.Thread.run(Thread.java:613)

cheers!

Re: What can connect to Processing Servers?
Reply #4 - May 6th, 2007, 10:12pm
 
Sorry, should have done some research before complaining that the server crashes - its a documented bug Smiley

However, my client app is a VB application running on a palm pilot, when i connect, everything works fine. When i disconnect, the server crashes.

I'm basing mine on the ValueServer example, if i comment out the myServer.write() command, my clients can connect and disconnect as they please, without the server falling over.

Is the server trying to send data to clients that aren't there any more? There is a ServerEvent() network event, but is that only triggered when a new client connects? Thats what the documentation suggests to me....

Anyone have any experience?

thanks in advance!
Re: What can connect to Processing Servers?
Reply #5 - May 14th, 2007, 5:11am
 
Yah, based on the stack trace I think what happens is that when a client disconnects the server winds up with a null reference that it tries to write to. I solved the issue in the Python script by only using one socket over the lifetime of the program. Even still, it shouldn't crash the server when a client disconnects.
Page Index Toggle Pages: 1