public void run() {
		// we don't expect this program to run on heavy load
		// everything runs in ONE thread!
		byte buffer[] = new byte[1024];

		while (true) {
			try {
				DatagramPacket p = new DatagramPacket(buffer, buffer.length);
				listenSocket.receive(p);
				if (p.getLength() == 0) {
					System.out.println("Exiting service thread");
					break;
				}
				DnsRequest request = new DnsRequest(buffer, p.getLength());
				int txnId = request.getTxnId();

				ArrayList<DnsQuestion> questions = request.getQuestions();
				synchronized(hostCache) {
					for (DnsQuestion question: questions) {
						String host = question.getDomainName();
						HostRecord record = resolve(host);
						// send back response, record may be null.
						byte reply[] = DnsResponse.constructPacket(record, txnId);
						DatagramPacket replyPkt = new DatagramPacket(reply, reply.length);
						replyPkt.setAddress(p.getAddress());
						replyPkt.setPort(p.getPort());
						listenSocket.send(replyPkt);

						//System.out.println("Served " + host + ": " + record);
					}
				}

			} catch (Exception ex) {
				ex.printStackTrace();
			}
		}
	}