是否有选择本地通信端口的最佳实践? [英] Are there Best Practises to select a Port for local cummunication?

查看:71
本文介绍了是否有选择本地通信端口的最佳实践?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我的本​​地系统上有一台服务器和客户端,通过网络进行通信。这意味着我必须使用网络端口。使用修复端口可能无法正常工作,因为该端口可能由不同的应用程序使用。但是,如果我使用随机的,客户端
如何知道端口号?


这种用例是否有最佳实践?


谢谢,


Daniel

解决方案

嗨丹尼尔,


>>"但是如果我使用随机的,客户端如何知道端口号?"


感谢您的发帖。如果您使用随机端口,我担心您需要在应用程序启动后将端口存储在共享位置。例如,将端口存储在可由客户端应用程序访问的共享文件夹或数据库中。


最好的问候,

李旺


Hi,

I have a server and client on my local System, communicate via network. This means I have to use a Network port. Using a fix port may not work because the port could be in use by a diffrent application. But in case I use a random one, how does the Client know the port number?

Are there any best practises for such a use case?

Thanks,

Daniel

解决方案

Hi Daniel,

>>"But in case I use a random one, how does the Client know the port number?"

Thank you for your post. If you use a random port, I am afraid you need to store the port in a shared place after your application started. For example, store the port in a shared folder or a database which could accessed by client application.

Best Regards,
Li Wang


这篇关于是否有选择本地通信端口的最佳实践?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆