javapns/src/main/java/javapns/notification/ResponsePacketReader.java
/**
	 * Read raw response packets from the provided socket.
	 * 
	 * Note: this method automatically sets the socket's timeout
	 * to TIMEOUT, so not to block the socket's input stream.
	 * 
	 * @param socket
	 * @return
	 */
Read raw response packets from the provided socket.

this method automatically sets the socket's timeout
to TIMEOUT, so not to block the socket's input stream.

@param socket
@return
Read raw response packets from the provided socket . this method automatically sets the socket ' s timeout to TIMEOUT so not to block the socket ' s input stream . @param socket @return
private static List<ResponsePacket> readResponses(Socket socket) {
		List<ResponsePacket> responses = new Vector<ResponsePacket>();
		int previousTimeout = 0;
		try {
			/* Set socket timeout to avoid getting stuck on read() */
			try {
				previousTimeout = socket.getSoTimeout();
				socket.setSoTimeout(TIMEOUT);
			} catch (Exception e) {
			}
			InputStream input = socket.getInputStream();
			while (true) {
				ResponsePacket packet = readResponsePacketData(input);
				if (packet != null) responses.add(packet);
				else break;
			}
		} catch (Exception e) {
			/* Ignore exception, as we are expecting timeout exceptions because Apple might not reply anything */
		}
		/* Reset socket timeout, just in case */
		try {
			socket.setSoTimeout(previousTimeout);
		} catch (Exception e) {
		}
		return responses;
	}
private static List < ResponsePacket > readResponses ( Socket socket ) { List < ResponsePacket > responses = new Vector < ResponsePacket > ( ) ; int previousTimeout = 0 ; try { /* Set socket timeout to avoid getting stuck on read() */ try { previousTimeout = socket . getSoTimeout ( ) ; socket . setSoTimeout ( TIMEOUT ) ; } catch ( Exception e ) { } InputStream input = socket . getInputStream ( ) ; while ( true ) { ResponsePacket packet = readResponsePacketData ( input ) ; if ( packet != null ) responses . add ( packet ) ; else break ; } } catch ( Exception e ) { /* Ignore exception, as we are expecting timeout exceptions because Apple might not reply anything */ } /* Reset socket timeout, just in case */ try { socket . setSoTimeout ( previousTimeout ) ; } catch ( Exception e ) { } return responses ; }
Read raw response packets from the provided socket.
Read raw response packets from the provided socket .
//System.out.println(e); //System.out.println("Received "+responses.size()+" response packets");