2

Why "java.nio.channels.AsynchronousSocket" always listen tcp port? If it could, how can I use it? Which classes are they?

Smoke
  • 31
  • 3

3 Answers3

3

They added it and then they removed it in ealier developement stage for jdk 7.

See this: http://bugs.java.com/view_bug.do?bug_id=6993126

La VloZ
  • 102
  • 10
0

UDP is done with the DatagramSocket. The nio functionality can be achieved by getting the associated channel.

Brett Okken
  • 6,210
  • 1
  • 19
  • 25
  • I might be wrong, but Channels / Selectors are not NIO.2, they belong to the old NIO pattern. – vbence Jul 13 '16 at 11:27
  • @vbence, yes - nio.2 is primarily focused on new ways to work with the file system. The question is really about nio, not nio.2. – Brett Okken Jul 15 '16 at 11:42
0

Because, as the Javadoc says, AsynchronousSocketChannel is 'an asynchronous channel for stream-oriented connecting sockets', i.e. TCP, and they didn't provide an AsynchronousDatagramChannel yet.

user207421
  • 305,947
  • 44
  • 307
  • 483