Added networking code

It's a quick hack right now, needs a lot of tidying up.