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.
IndexProcessing DevelopmentLibraries,  Tool Development › An alternative network library
Page Index Toggle Pages: 1
An alternative network library (Read 2540 times)
An alternative network library
May 23rd, 2009, 5:05am
 
Hi,

I'm involved in a project featuring computer vision on a large cluster. We ended up requiring a network library that works a bit different from the core processing one.

You can find the library at http://wiki.github.com/aginor/alternet.

The library uses the Java NIO package to perform asynchronous IO over the network while still keeping the library easy to use.
Everything is event-based except for the actual writing of data to the network. Like the processing core network library we provide a class for servers and a class for clients. In addition to this we provide a third class which is used to keep track of a hostname  and port pair.

The events that are supported in the current version are:
receiving of data
the server terminated the connection
a new client connected
the client terminated the connection

I currently provide two very simple examples, the first one being a chat server and the second one being a chat client.

The library has been tested with Processing 1.03 on Linux and Windows XP.

I hope that you will find this library useful.
Re: An alternative network library
Reply #1 - May 29th, 2009, 4:05am
 
Hi,

I've released version 0.92 today.
The main difference in this release is how the Server class is dealing with errors. The previous version could cause the server to abort prematurely whereas this version should handle errors more robustly.
Re: An alternative network library
Reply #2 - Aug 14th, 2009, 7:28am
 
Thanks for this - I think it's exactly what I need. However, I'm building something that needs to be able to gracefully reconnect upon exiting and I'm finding that the timeout for subsequent connection attempts is very long (the first attempt fails quickly). Here's the code I'm trying to use (in the setup() function):

Code:

while (!success && testIP < 25)
{
println("Running for testIP = " + testIP);
//Form our IP Address based on the testIP value
String lastIpNum = Integer.toString(testIP);
String ipAddress = "192.168.1." + lastIpNum;
//ipAddress = "192.168.1.20";

//Create a client and try connecting
client = new Client(this, ipAddress, 34567);

success = client.connect();
if(!success)
{
println("Failed to connect to " + ipAddress);
}
else
{
println("Connected successfully to " + ipAddress);

}
testIP++;
}


Any suggestions would be appreciated.
Re: An alternative network library
Reply #3 - Sep 11th, 2009, 4:46pm
 
Hi Jafish,

Sorry for the extremely late reply.

There are many factors that can make connection attempts fail slowly. The most common reason are firewalls that suppress the error message the network devices would otherwise send.

I can add a connect method that takes a timeout, if you want. I expect to release a new version of the library in the next few days.
Page Index Toggle Pages: 1