Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试在端口 3000 接收一些 UDP 数据包。但是,除了while()循环之外,我找不到检测是否以及何时收到数据包的方法。我很好奇是否有办法让我在填充数据包时得到通知,也许是事件处理程序或类似的东西?我正在使用 android API 10。谢谢。
while()
你使用 DatagramSocket 吗?因为在这种情况下,如果您使用接收方法,它会阻塞直到接收到数据报。