UDP server doesn't accept calls from outside

后端 未结 1 1414
半阙折子戏
半阙折子戏 2020-12-20 06:59

I\'ve implement simple udp server on my Android device.(sdk 1.5) it works fine when I am running a local client on the phone sends through it trigger to my server.

b

相关标签:
1条回答
  • 2020-12-20 07:42

    At a guess, I'm assuming that when you call InetAddress.getByName("localhost"), you are getting the loopback address (127.0.0.1).

    What you actually want to do is to have the socket bound to INADDR_ANY, which you can apparently achieve by creating your DatagramSocket like so:

    socket = new DatagramSocket(SERVERPORT);
    
    0 讨论(0)
提交回复
热议问题