是否有选择本地通信端口的最佳实践? [英] Are there Best Practises to select a Port for local cummunication?
问题描述
我的本地系统上有一台服务器和客户端,通过网络进行通信。这意味着我必须使用网络端口。使用修复端口可能无法正常工作,因为该端口可能由不同的应用程序使用。但是,如果我使用随机的,客户端
如何知道端口号?
这种用例是否有最佳实践?
谢谢,
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屋!