Added network test code found on StackOverflow