Friday, 30 December 2011

Java Network Client update 31/12/11

So Christmas has been and gone. Got some nice jumpers and spent some time with the family, so all in all good times. But this blog is not about my personal life (not entirely anyway) so back to the Java Network Client.

I'm going to be frank (you can be who ever you want), development has ground to a halt.
This isn't because I cant be bothered, but actually due to the way I'm trying to implement it. As you know the whole program is based around being able to send files and messages around a home network with a Central computer redirecting everything.So computer A sends a message to computer B by first telling the Central computer that it wants to send to B and with the central computer then passing the information on, like a relay.

The concept seems pretty simple, but once you start threading it all gets complicated. Let me explain.

When A connects to the central computer, the central computer stores its IP address (when A initially connects it sends its IP across the network automatically). This now means a separate thread for A has now been created. When B connects the same thing happens. The major issue I found though was where can i store the IP addresses and make the accessible to all the threads? 



Now this is where the blog post gets a little bit confusing, but hang on in there. Initially i was writing the above post, then i suddenly came up with a way of fixing the problem, so i focused on that for an hour and forgot about this post. So here i am a day later to complete it and share what happened:

The solution didn't work.

I'll get back to what i was going to say...

So, the solution to the IP problem has been elusive to say the least. Actually that's not true; a working solution is a far better way to describe what's going on. When I first encounter the whole storing problem, I thought I could just store the IP in an array within an Object (coding term; look it up), but this wont work, as each thread would create a brand new Object to store the array, and thus NONE of the connected computers would have a complete array.

Ok, I understand that for people who don't do this stuff is all a bit "wha?", and i will write about Objects soon. But this has led to a seriously hard problem. How do I create a central store for all the IP data where each thread can access and update?
The idea I had was to create a separate file that stores the Object which contains the IP addresses. This file can then be accessed by any thread! Of course there are a few problems with using this methods which i will elaborate on in a later blog post, but the idea to me seems pretty sound. Well it would be if I could get it working!

For some bazaar reason when I read and write to files from the program it just fails! So with out a decent way to store the IPs I can't get more than interaction between the Central computer and a computer connected. Very annoying!

So at the moment I'm at a loss. Over the coming weeks i will keep working at it, and find away around it. When I'm back at University I'll ask around to see what I'm doing wrong or for other ideas.
In the mean time keep a lookout on my twitter to see updates, and if you want to help then leave a comment!

Hazz 22

Merry Christmas and a Happy New Year!      

  

No comments:

Post a Comment