Hard to say whether this is one way to do it, or the only way. (E.g. "Unlike stationary Doze, wake locks (apps requesting the phone stay awake so they can do background tasks) are still allowed.")
[0] http://arstechnica.com/gadgets/2016/08/android-7-0-nougat-re...
A wake lock is possible, but it’s far more battery intensive than just using the pre-Nougat solutions.
Pre-Nougat, I could keep a socket open, and only have a timeout message sent every 28 minutes to keep it open – at very low battery cost.
Now I either have to keep a wakelock – keeping the CPU always on, instead of just a few milliseconds per hour – or I can’t use it at all.
That’s a severe issue for me.
(I can’t use GCM, due to architectural reasons, and would have to ask tenthousands of people to change their IRC bouncer setup completely).