Updated networking to use NIO

Resets the connection when it gets interrupted.