Skip to content

Instantly share code, notes, and snippets.

@enebo
Created March 31, 2011 20:19
Show Gist options
  • Save enebo/897171 to your computer and use it in GitHub Desktop.
Save enebo/897171 to your computer and use it in GitHub Desktop.
A.java
import java.net.InetSocketAddress;
import java.nio.channels.DatagramChannel;
public class A {
public static void main(String[] args) {
try {
InetSocketAddress addr = new InetSocketAddress(4321);
DatagramChannel channel = DatagramChannel.open();
System.out.println("Connected: " + channel.isConnected());
System.out.println("Bound: " + channel.socket().isBound());
System.out.println("Connected: " + channel.socket().isConnected());
System.out.println("Closed: " + channel.socket().isClosed());
System.out.println("Localport: " + channel.socket().getLocalPort());
System.out.println("Connected: " + channel.isConnected());
channel.socket().bind(addr);
} catch (Exception e) {
System.out.println("E: " + e);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment