我应该为我的 WCF P2P 应用程序分配一个端口吗?
我正在使用 PNRP 功能构建 WCF P2P 服务。
我发现我可以为绑定分配端口...但大多数示例都不能。 我是否有理由应该或不应该给它一个端口?
I'm building a WCF P2P service using the PNRP functionality.
I see that I can assign a port to the Bindings... but most of the examples do not.
Is there a reason I should or shouldn't give it a port?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您不分配端口,WCF 将自动选择一个随机可用端口。作为 PNRP 过程的一部分,本地端口信息会广播给对等点,因此显式设置本地端口比其他任何事情都更能让您的应用程序变得可预测。
我通常明确设置我的端口,以便我可以将它们记录给我的客户。当客户使用我无法在代码中轻松配置的第三方防火墙时,这一点尤其重要。如果您的应用程序分配了随机端口,他们将不知道要在防火墙软件中解锁哪个端口。
If you don't assign a port, WCF will choose a random available port automatically. The local port information is broadcast to peers as part of the PNRP process, so setting a local port explicitly is more to make your application predictable than anything else.
I usually set my ports explicitly so that I can document them to my customers. This is especially important when a customer uses a 3rd party firewall that I can't easily configure in code. If your app assigns a random port, they won't know what port to unblock in their firewall software.