Java Code Examples for java.nio.channels.DatagramChannel#disconnect()
The following examples show how to use
java.nio.channels.DatagramChannel#disconnect() .
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: ChangingAddress.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { InetAddress lh = InetAddress.getLocalHost(); SocketAddress remote = new InetSocketAddress(lh, 1234); DatagramSocket ds = null; DatagramChannel dc = null; try { ds = new DatagramSocket(); dc = DatagramChannel.open().bind(new InetSocketAddress(0)); check(ds, dc); ds.connect(remote); dc.connect(remote); check(ds, dc); ds.disconnect(); dc.disconnect(); check(ds, dc); // repeat tests using socket adapter ds.connect(remote); dc.socket().connect(remote); check(ds, dc); ds.disconnect(); dc.socket().disconnect(); check(ds, dc); } finally { if (ds != null) ds.close(); if (dc != null) dc.close(); } }
Example 2
Source File: ChangingAddress.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { InetAddress lh = InetAddress.getLocalHost(); SocketAddress remote = new InetSocketAddress(lh, 1234); DatagramSocket ds = null; DatagramChannel dc = null; try { ds = new DatagramSocket(); dc = DatagramChannel.open().bind(new InetSocketAddress(0)); check(ds, dc); ds.connect(remote); dc.connect(remote); check(ds, dc); ds.disconnect(); dc.disconnect(); check(ds, dc); // repeat tests using socket adapter ds.connect(remote); dc.socket().connect(remote); check(ds, dc); ds.disconnect(); dc.socket().disconnect(); check(ds, dc); } finally { if (ds != null) ds.close(); if (dc != null) dc.close(); } }
Example 3
Source File: ChangingAddress.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { InetAddress lh = InetAddress.getLocalHost(); SocketAddress remote = new InetSocketAddress(lh, 1234); DatagramSocket ds = null; DatagramChannel dc = null; try { ds = new DatagramSocket(); dc = DatagramChannel.open().bind(new InetSocketAddress(0)); check(ds, dc); ds.connect(remote); dc.connect(remote); check(ds, dc); ds.disconnect(); dc.disconnect(); check(ds, dc); // repeat tests using socket adapter ds.connect(remote); dc.socket().connect(remote); check(ds, dc); ds.disconnect(); dc.socket().disconnect(); check(ds, dc); } finally { if (ds != null) ds.close(); if (dc != null) dc.close(); } }
Example 4
Source File: ChangingAddress.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { InetAddress lh = InetAddress.getLocalHost(); SocketAddress remote = new InetSocketAddress(lh, 1234); DatagramSocket ds = null; DatagramChannel dc = null; try { ds = new DatagramSocket(); dc = DatagramChannel.open().bind(new InetSocketAddress(0)); check(ds, dc); ds.connect(remote); dc.connect(remote); check(ds, dc); ds.disconnect(); dc.disconnect(); check(ds, dc); // repeat tests using socket adapter ds.connect(remote); dc.socket().connect(remote); check(ds, dc); ds.disconnect(); dc.socket().disconnect(); check(ds, dc); } finally { if (ds != null) ds.close(); if (dc != null) dc.close(); } }
Example 5
Source File: NioDatagramAcceptor.java From neoscada with Eclipse Public License 1.0 | 5 votes |
@Override protected void close(DatagramChannel handle) throws Exception { SelectionKey key = handle.keyFor(selector); if (key != null) { key.cancel(); } handle.disconnect(); handle.close(); }
Example 6
Source File: ChangingAddress.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { InetAddress lh = InetAddress.getLocalHost(); SocketAddress remote = new InetSocketAddress(lh, 1234); DatagramSocket ds = null; DatagramChannel dc = null; try { ds = new DatagramSocket(); dc = DatagramChannel.open().bind(new InetSocketAddress(0)); check(ds, dc); ds.connect(remote); dc.connect(remote); check(ds, dc); ds.disconnect(); dc.disconnect(); check(ds, dc); // repeat tests using socket adapter ds.connect(remote); dc.socket().connect(remote); check(ds, dc); ds.disconnect(); dc.socket().disconnect(); check(ds, dc); } finally { if (ds != null) ds.close(); if (dc != null) dc.close(); } }
Example 7
Source File: ChangingAddress.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { InetAddress lh = InetAddress.getLocalHost(); SocketAddress remote = new InetSocketAddress(lh, 1234); DatagramSocket ds = null; DatagramChannel dc = null; try { ds = new DatagramSocket(); dc = DatagramChannel.open().bind(new InetSocketAddress(0)); check(ds, dc); ds.connect(remote); dc.connect(remote); check(ds, dc); ds.disconnect(); dc.disconnect(); check(ds, dc); // repeat tests using socket adapter ds.connect(remote); dc.socket().connect(remote); check(ds, dc); ds.disconnect(); dc.socket().disconnect(); check(ds, dc); } finally { if (ds != null) ds.close(); if (dc != null) dc.close(); } }
Example 8
Source File: ChangingAddress.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { InetAddress lh = InetAddress.getLocalHost(); SocketAddress remote = new InetSocketAddress(lh, 1234); DatagramSocket ds = null; DatagramChannel dc = null; try { ds = new DatagramSocket(); dc = DatagramChannel.open().bind(new InetSocketAddress(0)); check(ds, dc); ds.connect(remote); dc.connect(remote); check(ds, dc); ds.disconnect(); dc.disconnect(); check(ds, dc); // repeat tests using socket adapter ds.connect(remote); dc.socket().connect(remote); check(ds, dc); ds.disconnect(); dc.socket().disconnect(); check(ds, dc); } finally { if (ds != null) ds.close(); if (dc != null) dc.close(); } }
Example 9
Source File: ChangingAddress.java From hottub with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { InetAddress lh = InetAddress.getLocalHost(); SocketAddress remote = new InetSocketAddress(lh, 1234); DatagramSocket ds = null; DatagramChannel dc = null; try { ds = new DatagramSocket(); dc = DatagramChannel.open().bind(new InetSocketAddress(0)); check(ds, dc); ds.connect(remote); dc.connect(remote); check(ds, dc); ds.disconnect(); dc.disconnect(); check(ds, dc); // repeat tests using socket adapter ds.connect(remote); dc.socket().connect(remote); check(ds, dc); ds.disconnect(); dc.socket().disconnect(); check(ds, dc); } finally { if (ds != null) ds.close(); if (dc != null) dc.close(); } }
Example 10
Source File: ChangingAddress.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { InetAddress lh = InetAddress.getLocalHost(); SocketAddress remote = new InetSocketAddress(lh, 1234); DatagramSocket ds = null; DatagramChannel dc = null; try { ds = new DatagramSocket(); dc = DatagramChannel.open().bind(new InetSocketAddress(0)); check(ds, dc); ds.connect(remote); dc.connect(remote); check(ds, dc); ds.disconnect(); dc.disconnect(); check(ds, dc); // repeat tests using socket adapter ds.connect(remote); dc.socket().connect(remote); check(ds, dc); ds.disconnect(); dc.socket().disconnect(); check(ds, dc); } finally { if (ds != null) ds.close(); if (dc != null) dc.close(); } }
Example 11
Source File: ChangingAddress.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { InetAddress lh = InetAddress.getLocalHost(); SocketAddress remote = new InetSocketAddress(lh, 1234); DatagramSocket ds = null; DatagramChannel dc = null; try { ds = new DatagramSocket(); dc = DatagramChannel.open().bind(new InetSocketAddress(0)); check(ds, dc); ds.connect(remote); dc.connect(remote); check(ds, dc); ds.disconnect(); dc.disconnect(); check(ds, dc); // repeat tests using socket adapter ds.connect(remote); dc.socket().connect(remote); check(ds, dc); ds.disconnect(); dc.socket().disconnect(); check(ds, dc); } finally { if (ds != null) ds.close(); if (dc != null) dc.close(); } }
Example 12
Source File: ChangingAddress.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { InetAddress lh = InetAddress.getLocalHost(); SocketAddress remote = new InetSocketAddress(lh, 1234); DatagramSocket ds = null; DatagramChannel dc = null; try { ds = new DatagramSocket(); dc = DatagramChannel.open().bind(new InetSocketAddress(0)); check(ds, dc); ds.connect(remote); dc.connect(remote); check(ds, dc); ds.disconnect(); dc.disconnect(); check(ds, dc); // repeat tests using socket adapter ds.connect(remote); dc.socket().connect(remote); check(ds, dc); ds.disconnect(); dc.socket().disconnect(); check(ds, dc); } finally { if (ds != null) ds.close(); if (dc != null) dc.close(); } }
Example 13
Source File: ChangingAddress.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { InetAddress lh = InetAddress.getLocalHost(); SocketAddress remote = new InetSocketAddress(lh, 1234); DatagramSocket ds = null; DatagramChannel dc = null; try { ds = new DatagramSocket(); dc = DatagramChannel.open().bind(new InetSocketAddress(0)); check(ds, dc); ds.connect(remote); dc.connect(remote); check(ds, dc); ds.disconnect(); dc.disconnect(); check(ds, dc); // repeat tests using socket adapter ds.connect(remote); dc.socket().connect(remote); check(ds, dc); ds.disconnect(); dc.socket().disconnect(); check(ds, dc); } finally { if (ds != null) ds.close(); if (dc != null) dc.close(); } }
Example 14
Source File: ChangingAddress.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { InetAddress lh = InetAddress.getLocalHost(); SocketAddress remote = new InetSocketAddress(lh, 1234); DatagramSocket ds = null; DatagramChannel dc = null; try { ds = new DatagramSocket(); dc = DatagramChannel.open().bind(new InetSocketAddress(0)); check(ds, dc); ds.connect(remote); dc.connect(remote); check(ds, dc); ds.disconnect(); dc.disconnect(); check(ds, dc); // repeat tests using socket adapter ds.connect(remote); dc.socket().connect(remote); check(ds, dc); ds.disconnect(); dc.socket().disconnect(); check(ds, dc); } finally { if (ds != null) ds.close(); if (dc != null) dc.close(); } }
Example 15
Source File: NioDatagramConnector.java From neoscada with Eclipse Public License 1.0 | 4 votes |
@Override protected void close(DatagramChannel handle) throws Exception { handle.disconnect(); handle.close(); }