Adds Socket::encode and Socket::decode hooks.