[英]How to change UDP broadcast port in the server if client's port is already occupied during server discovery?
I am trying to implement a server discovery between a PC (server) and an android phone, broadcasting a message from the server on a common port (8888). 我正在尝试在PC(服务器)和Android手机之间实现服务器发现,在公共端口(8888)上从服务器广播消息。 I wonder what should I do if the port is already taken in the client, how can I change port on both, so that the client receives the broadcast message?
我想知道如果端口已经在客户端中,我应该怎么做,如何更改端口,以便客户端接收广播消息? Should I use any specific network discovery protocol (UPnP or similar)?
我应该使用任何特定的网络发现协议(UPnP或类似的)吗?
Sorry if it is a basic question but I am not familiar with network programming. 对不起,如果这是一个基本问题,但我不熟悉网络编程。 I will edit my question according to your observations.
我会根据你的观察编辑我的问题。
I could only find this, but it has no answer: How to listen for a UDP broadcast when the default port could be already taken 我只能找到这个,但它没有答案: 如何在已经采用默认端口时监听UDP广播
Ideally, use an existing service discovery protocol like SSDP. 理想情况下,使用现有的服务发现协议,如SSDP。 There is some prior work on this for Android you may be able to build from: https://github.com/resourcepool/ssdp-client
有一些关于Android的先前工作,您可以从以下构建: https : //github.com/resourcepool/ssdp-client
The reasons to use SSDP: 使用SSDP的原因:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.