fixing infinite loops in socketIO

        - copying stevie's fixes for infinite loops in socketIO
        - both read and write can loop forever, this is a sanity check for that