简体   繁体   中英

Android - DatagramSocket with source port 800 not sending

I have a little tool which sends UDP packets from port 800 (Android) to a PC (Windows) on port 804 , so im using DatagramSocket(800) , it just doesnt work while (almost) all other ports work (usually 4 digits ports) so i was wondering if 800 is reserved on Android (i tried netstat and couldnt find something using port 800) and if there is any work around it (except Rooting). I cant really change the ports because they are fixed , so its either 800->804 or nothing will work!

Thank you in Advance.

On Linux you have to hold root privileges to be able to bind to port lower than 1024. Unless you are able to make your app privileges elevated and act as root (at least for while binding, you can later drop back to regular user as most software utilizing "lower" ports do), you must choose other port to succeed. That's why your "4 digits port number" tests works (yet ie 1000 would fail :), while 800 not.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM