Updated networking to use NIO

Extracted from the now deleted Message class.