IPC端口范围 [英] IPC port ranges

查看:97
本文介绍了IPC端口范围的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

IPC可以通过TCP/IP套接字来完成.Windows下程序之间的本地IPC应该使用哪个端口范围?
我使用哪个Windows版本有关系吗?
如果我想跨平台兼容,在Linux下有什么不同吗?
我写什么语言有关系吗?
IPC是本地的还是无关紧要的?

IPC can be done via TCP/IP sockets. Which port ranges should I use for local IPC between programs under windows?
Does it matter which Windows version I'm using?
In case I'd like to be cross-platform compatible, is it any different under Linux?
Does it matter what language I write in?
Does it matter if the IPC is local or not?

推荐答案

原则上,如果要广泛使用您的程序,则应按照

In principle, if your program is going to be used widely, you should get a port number assigned to you by IANA as per RFC6335. If you don't qualify for an assignment your program should choose an unused port in the 49152-65535 range at run-time and communicate this port number to the other processes by some other means.

实际上,尽管应该允许其他程序使用它,但通常可以避免使用1024-49151范围内的任何不常用端口.通常,这是通过允许用户配置其他端口的使用来完成的,例如,您可以使用注册表设置.

In practice, you can usually get away with using any infrequently-used port in the range 1024-49151, although you should allow for the possibility that another program will be using it. Typically this is done by allowing the user to configure use of a different port, e.g., you could use a registry setting.

可以查看分配的端口号在IANA 中.此列表可能有助于避免特别可能正在使用的端口.

Assigned port numbers can be viewed at IANA. This list may be helpful in avoiding ports that are particularly likely to be in use.

为便于记录,在Windows上通常更容易使用其他IPC方法,例如命名管道.

For the record, on Windows it is usually simpler to use some other IPC method such as named pipes.

这篇关于IPC端口范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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