Added networking code

It's a quick hack right now, needs a lot of tidying up. Network code will not build currently, needs refactoring and libs.