Code example for DatagramChannel

Methods: receive

	public void readInboundData (ByteBuffer dst) {
		returnAddress = null;
		try { 
			// If there is no datagram available (we're nonblocking after all), 
			// then channel.receive returns null. 
			returnAddress = channel.receive(dst);
		} catch (IOException e) {
			// probably a no-op. The caller will see the empty (or even partial) buffer 
			// and presumably do the right thing. 
	public boolean writeOutboundData() { 
		while (!outboundQ.isEmpty()) {
			Packet p = outboundQ.getFirst();
			int written = 0;
			try { 
				// With a datagram socket, it's ok to send an empty buffer. 
				written = channel.send(, p.recipient);
Connect your IDE to all the code out there  Get Codota for Java