UPnP 自动选择外部端口
我正在尝试创建一个应用程序,在必要时使用 UPnP 打开端口,以便可以接收传入的传输。问题是,我不想指定外部端口(因为第一,外部端口对于找到应用程序并不重要,第二,我想确保同一路由器上的多个人可以使用该应用程序,并且共享端口显然不是一种选择)。我正在查看的 API 都没有说明开始能够不指定端口,但会发送诸如 0
或 -1
之类的内容,导致它自己选择端口,或者我必须选择一个随机数并希望得到最好的结果?
另外,端口映射是否会过期,或者我是否必须强制取消所有端口映射?我想知道万一应用程序崩溃或计算机断电或其他什么情况。
I am trying to make an application that utilizes UPnP if necessary to open ports so incoming transmissions can be received. The thing is, I don't want to specify an external port (because one, the external port doesn't matter for the application to be found, and two, I want to make sure multiple people on the same router can use the application, and sharing a port is not an option, obviously). None of the API's I'm looking at says anything about begin able to not specifying a port, but would sending something like 0
or -1
cause it to choose a port itself, or do I have to choose a random number and hope for the best?
Also, will the port mappings ever expire, or do I have to forcefully de-map all of them? I was wondering for in-case the application crashes or the computer looses power or something.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论