Thanks for that.
I've found with a lot of problems with arduino, it's like a jigsaw. The more pieces you get in place, the clearer it becomes.
It helps knowing this stuff, i mistakenly thought that much of this was just to do with web applications.
You live and learn.