Java Code Examples for java.nio.channels.DatagramChannel#getLocalAddress()
The following examples show how to use
java.nio.channels.DatagramChannel#getLocalAddress() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NotBound.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
static void wakeupWhenBound(final DatagramChannel dc) { Runnable wakeupTask = new Runnable() { public void run() { try { // poll for local address InetSocketAddress local; do { Thread.sleep(50); local = (InetSocketAddress)dc.getLocalAddress(); } while (local == null); // send message to channel to wakeup receiver DatagramChannel sender = DatagramChannel.open(); try { ByteBuffer bb = ByteBuffer.wrap("hello".getBytes()); InetAddress lh = InetAddress.getLocalHost(); SocketAddress target = new InetSocketAddress(lh, local.getPort()); sender.send(bb, target); } finally { sender.close(); } } catch (Exception x) { x.printStackTrace(); } }}; new Thread(wakeupTask).start(); }
Example 2
Source File: NotBound.java From hottub with GNU General Public License v2.0 | 5 votes |
static void wakeupWhenBound(final DatagramChannel dc) { Runnable wakeupTask = new Runnable() { public void run() { try { // poll for local address InetSocketAddress local; do { Thread.sleep(50); local = (InetSocketAddress)dc.getLocalAddress(); } while (local == null); // send message to channel to wakeup receiver DatagramChannel sender = DatagramChannel.open(); try { ByteBuffer bb = ByteBuffer.wrap("hello".getBytes()); InetAddress lh = InetAddress.getLocalHost(); SocketAddress target = new InetSocketAddress(lh, local.getPort()); sender.send(bb, target); } finally { sender.close(); } } catch (Exception x) { x.printStackTrace(); } }}; new Thread(wakeupTask).start(); }
Example 3
Source File: NotBound.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
static void wakeupWhenBound(final DatagramChannel dc) { Runnable wakeupTask = new Runnable() { public void run() { try { // poll for local address InetSocketAddress local; do { Thread.sleep(50); local = (InetSocketAddress)dc.getLocalAddress(); } while (local == null); // send message to channel to wakeup receiver DatagramChannel sender = DatagramChannel.open(); try { ByteBuffer bb = ByteBuffer.wrap("hello".getBytes()); InetAddress lh = InetAddress.getLocalHost(); SocketAddress target = new InetSocketAddress(lh, local.getPort()); sender.send(bb, target); } finally { sender.close(); } } catch (Exception x) { x.printStackTrace(); } }}; new Thread(wakeupTask).start(); }
Example 4
Source File: NotBound.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
static void wakeupWhenBound(final DatagramChannel dc) { Runnable wakeupTask = new Runnable() { public void run() { try { // poll for local address InetSocketAddress local; do { Thread.sleep(50); local = (InetSocketAddress)dc.getLocalAddress(); } while (local == null); // send message to channel to wakeup receiver DatagramChannel sender = DatagramChannel.open(); try { ByteBuffer bb = ByteBuffer.wrap("hello".getBytes()); InetAddress lh = InetAddress.getLocalHost(); SocketAddress target = new InetSocketAddress(lh, local.getPort()); sender.send(bb, target); } finally { sender.close(); } } catch (Exception x) { x.printStackTrace(); } }}; new Thread(wakeupTask).start(); }
Example 5
Source File: NotBound.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
static void wakeupWhenBound(final DatagramChannel dc) { Runnable wakeupTask = new Runnable() { public void run() { try { // poll for local address InetSocketAddress local; do { Thread.sleep(50); local = (InetSocketAddress)dc.getLocalAddress(); } while (local == null); // send message to channel to wakeup receiver DatagramChannel sender = DatagramChannel.open(); try { ByteBuffer bb = ByteBuffer.wrap("hello".getBytes()); InetAddress lh = InetAddress.getLocalHost(); SocketAddress target = new InetSocketAddress(lh, local.getPort()); sender.send(bb, target); } finally { sender.close(); } } catch (Exception x) { x.printStackTrace(); } }}; new Thread(wakeupTask).start(); }
Example 6
Source File: NotBound.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
static void wakeupWhenBound(final DatagramChannel dc) { Runnable wakeupTask = new Runnable() { public void run() { try { // poll for local address InetSocketAddress local; do { Thread.sleep(50); local = (InetSocketAddress)dc.getLocalAddress(); } while (local == null); // send message to channel to wakeup receiver DatagramChannel sender = DatagramChannel.open(); try { ByteBuffer bb = ByteBuffer.wrap("hello".getBytes()); InetAddress lh = InetAddress.getLocalHost(); SocketAddress target = new InetSocketAddress(lh, local.getPort()); sender.send(bb, target); } finally { sender.close(); } } catch (Exception x) { x.printStackTrace(); } }}; new Thread(wakeupTask).start(); }
Example 7
Source File: NotBound.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
static void wakeupWhenBound(final DatagramChannel dc) { Runnable wakeupTask = new Runnable() { public void run() { try { // poll for local address InetSocketAddress local; do { Thread.sleep(50); local = (InetSocketAddress)dc.getLocalAddress(); } while (local == null); // send message to channel to wakeup receiver DatagramChannel sender = DatagramChannel.open(); try { ByteBuffer bb = ByteBuffer.wrap("hello".getBytes()); InetAddress lh = InetAddress.getLocalHost(); SocketAddress target = new InetSocketAddress(lh, local.getPort()); sender.send(bb, target); } finally { sender.close(); } } catch (Exception x) { x.printStackTrace(); } }}; new Thread(wakeupTask).start(); }
Example 8
Source File: EmptyBuffer.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private static void test() throws Exception { DatagramChannel dc = DatagramChannel.open(); InetAddress localHost = InetAddress.getLocalHost(); dc.bind(new InetSocketAddress(localHost, 0)); Server server = new Server(dc.getLocalAddress()); Thread serverThread = new Thread(server); serverThread.start(); try { InetSocketAddress isa = new InetSocketAddress(localHost, server.port()); dc.connect(isa); ByteBuffer bb = ByteBuffer.allocateDirect(12); bb.order(ByteOrder.BIG_ENDIAN); bb.putInt(1).putLong(1); bb.flip(); dc.write(bb); bb.rewind(); dc.write(bb); bb.rewind(); dc.write(bb); Thread.sleep(2000); serverThread.interrupt(); server.throwException(); } finally { dc.close(); } }
Example 9
Source File: NotBound.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
static void wakeupWhenBound(final DatagramChannel dc) { Runnable wakeupTask = new Runnable() { public void run() { try { // poll for local address InetSocketAddress local; do { Thread.sleep(50); local = (InetSocketAddress)dc.getLocalAddress(); } while (local == null); // send message to channel to wakeup receiver DatagramChannel sender = DatagramChannel.open(); try { ByteBuffer bb = ByteBuffer.wrap("hello".getBytes()); InetAddress lh = InetAddress.getLocalHost(); SocketAddress target = new InetSocketAddress(lh, local.getPort()); sender.send(bb, target); } finally { sender.close(); } } catch (Exception x) { x.printStackTrace(); } }}; new Thread(wakeupTask).start(); }
Example 10
Source File: NotBound.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
static void checkBound(DatagramChannel dc) throws IOException { if (dc.getLocalAddress() == null) throw new RuntimeException("Not bound??"); }
Example 11
Source File: NotBound.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
static void checkBound(DatagramChannel dc) throws IOException { if (dc.getLocalAddress() == null) throw new RuntimeException("Not bound??"); }
Example 12
Source File: NotBound.java From hottub with GNU General Public License v2.0 | 4 votes |
static void checkBound(DatagramChannel dc) throws IOException { if (dc.getLocalAddress() == null) throw new RuntimeException("Not bound??"); }
Example 13
Source File: NotBound.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
static void checkBound(DatagramChannel dc) throws IOException { if (dc.getLocalAddress() == null) throw new RuntimeException("Not bound??"); }
Example 14
Source File: NotBound.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
static void checkBound(DatagramChannel dc) throws IOException { if (dc.getLocalAddress() == null) throw new RuntimeException("Not bound??"); }
Example 15
Source File: NotBound.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
static void checkBound(DatagramChannel dc) throws IOException { if (dc.getLocalAddress() == null) throw new RuntimeException("Not bound??"); }
Example 16
Source File: NotBound.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
static void checkBound(DatagramChannel dc) throws IOException { if (dc.getLocalAddress() == null) throw new RuntimeException("Not bound??"); }
Example 17
Source File: NotBound.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
static void checkBound(DatagramChannel dc) throws IOException { if (dc.getLocalAddress() == null) throw new RuntimeException("Not bound??"); }
Example 18
Source File: NotBound.java From jdk8u_jdk with GNU General Public License v2.0 | 4 votes |
static void checkBound(DatagramChannel dc) throws IOException { if (dc.getLocalAddress() == null) throw new RuntimeException("Not bound??"); }
Example 19
Source File: NotBound.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
static void checkBound(DatagramChannel dc) throws IOException { if (dc.getLocalAddress() == null) throw new RuntimeException("Not bound??"); }
Example 20
Source File: NotBound.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 4 votes |
static void checkBound(DatagramChannel dc) throws IOException { if (dc.getLocalAddress() == null) throw new RuntimeException("Not bound??"); }