手機間發送和接受udp廣播
在手機都連的是路由是是沒問題的 但是在手機用自帶的wifi熱點連接時
發送端發送udp廣播時會拋出以下錯誤
java.net.SocketException: sendto failed: ENETUNREACH (Network is unreachable)
at libcore.io.IoBridge.maybeThrowAfterSendto(IoBridge.java:541)
at libcore.io.IoBridge.sendto(IoBridge.java:510)
at java.net.PlainDatagramSocketImpl.send(PlainDatagramSocketImpl.java:182)
at java.net.DatagramSocket.send(DatagramSocket.java:284)
at com.example.udp_sreverdemo.SendThead.run(SendThead.java:97)
Caused by: libcore.io.ErrnoException: sendto failed: ENETUNREACH (Network is unreachable)
at libcore.io.Posix.sendtoBytes(Native Method)
at libcore.io.Posix.sendto(Posix.java:146)
at libcore.io.BlockGuardOs.sendto(BlockGuardOs.java:177)
at libcore.io.IoBridge.sendto(IoBridge.java:508)
注 : 在手機用自帶的wifi熱點連接時 是可以ping通的
路由配置問題?檢查一下wifi熱點模式下client和server的路由表吧。