2

According to this post, UDP just doesn't block. Are there any advantage using the (non-blocking) NIO API for UDP? Or should I just use the easier "traditional" io API?

Community
  • 1
  • 1
J-16 SDiZ
  • 26,473
  • 4
  • 65
  • 84

2 Answers2

2

At the risk of just pointing you back, the comments to that post explain that UDP doesn't block on the TCP ACK, but you could still block on a kernel buffer overflow. This would happen only if you have a very big UDP burst.

MSalters
  • 173,980
  • 10
  • 155
  • 350
0

If you are working with a large number of streams, it may help you to have a dedicate threading model to handle those sockets. NIO provides some of the work (selectors) that would help.

Jim Rush
  • 4,143
  • 3
  • 25
  • 27
  • can NIO be used to listen to UDP broadcast from a server to an android phone. Is there any problem if i constantly receive and listen to UDP signals using the traditional way in android, because in my case after working for long time its not listening to packets. – George Thomas Sep 02 '16 at 04:27
  • I haven't, but this post (read all responses) indicates it can be: http://stackoverflow.com/questions/17472781/java-nio-udp-broadcast – Jim Rush Sep 02 '16 at 16:34