code: public void loop() throws IOException
  	{
  		final long start = System.currentTimeMillis();
  
  		final byte[] buf = new byte[maxRcvBuf];
  		try {
  			if (timeout > 0)
  				s.setSoTimeout(timeout);
  			while (!quit) {
  				if (total > 0) {
  					final long now = System.currentTimeMillis();
  					int to = (int) (start + total - now);
  					if (to <= 0)
  						break;
  					// query socket timeout directly from socket since subtypes might
  					// have modified the timeout during looping
  					final int sto = s.getSoTimeout();
  					if (sto > 0)
  						to = Math.min(to, sto);
  					s.setSoTimeout(to);
  				}
  				try {
  					final DatagramPacket p = new DatagramPacket(buf, buf.length);
  					s.receive(p);
  					final byte[] data = p.getData();
  					onReceive((InetSocketAddress) p.getSocketAddress(), data, p.getOffset(), p.getLength());
  				}
  				catch (final SocketTimeoutException e) {
  					if (total == 0 || start + total > System.currentTimeMillis())
  						onTimeout();
  				}
  				catch (final IOException e) {
  					if (!reboundSocket)
  						throw e;
  					reboundSocket = false;
  				}
  			}
  		}
  		catch (final InterruptedIOException e) {
  			Thread.currentThread().interrupt();
  		}
  		catch (final IOException e) {
  			if (!quit)
  				throw e;
  		}
  		finally {
  			quit();
  		}
  	}
docs: Runs the looper.
  
  @throws IOException on socket I/O error