private boolean readPacket(final InputStream in, final byte[] bytes) throws IOException {
                final int len = bytes.length;
                int n = 0;
                while (n < len) {
                    try {
                        int count = in.read(bytes, n, len - n);
                        if (count < 0) {
                            throw new EOFException("EOF after reading "+n+" bytes of new packet.");
                        }
                        n += count;
                    } catch (IOException ioe) {
                        if (n == 0)
                            return false;
                        throw new IOException("Error after reading "+n+" bytes of packet", ioe);
                    }
                }
                return true;
            }
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