简体   繁体   English

Android-源端口为800的DatagramSocket无法发送

[英]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). 我有一个小工具可以将UDP数据包从端口800(Android)发送到端口804上的PC(Windows),因此我使用DatagramSocket(800)时(几乎)所有其他端口都可以正常工作(通常是4位数端口) ),所以我想知道是否在Android上保留了800(我尝试过netstat并使用端口800无法找到某些东西),以及周围是否有任何工作(除Rooting外)。 I cant really change the ports because they are fixed , so its either 800->804 or nothing will work! 我不能真正更改端口,因为它们是固定的,所以它的800-> 804或什么都不起作用!

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. 在Linux上,您必须拥有root特权才能绑定到低于1024的端口。除非您能够提高应用程序特权并以root身份运行(至少在绑定时,否则以后您可以像大多数用户一样退回到常规用户使用“较低”端口的软件),则必须选择其他端口才能成功。 That's why your "4 digits port number" tests works (yet ie 1000 would fail :), while 800 not. 这就是为什么您的“ 4位数端口号”测试有效的原因(然而,即1000将失败:),而800则不行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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