private synchronized void drainBuffer() {
        logger.debug("draining buffer");
        while (!notificationsBuffer.isEmpty()) {
            final ApnsNotification notification = notificationsBuffer.poll();
            try {
                sendMessage(notification, true);
            }
            catch (NetworkIOException ex) {
                // at this point we are retrying the submission of messages but failing to connect to APNS, therefore
                // notify the client of this
                delegate.messageSendFailed(notification, ex);
            }
        }
    }
Read a packet like in.readFully(bytes) does - but do not throw an exception and return false if nothing
could be read at all.
@param in the input stream
@param bytes the array to be filled with data
@return true if a packet as been read, false if the stream was at EOF right at the beginning.
@throws IOException When a problem occurs, especially EOFException when there's an EOF in the middle of the packet.
src/main/java/com/notnoop/apns/internal/ApnsConnectionImpl.java