Change throw 1 to throw std::exceptions

Fixed a small bug with writing packets