0

我有一个遗留源文件,它在扩展名为 .x 文件的文件中描述了用于 RPC 的协议,该文件被馈送到 rpcgen 以生成协议所需的存根文件。但是,目前在生成的存根文件中,RPC 客户端可以自由地从任何端口连接(或侦听)。因为在生成的文件中,我看到以下内容

transp = svctcp_create(RPC_ANYSOCK, 0, 0);

我是 RPC 和相关事物的新手,但无论如何都试图修改它....由于我知道服务器侦听特定端口,我推断上面的行是导致客户端从任意端口连接的原因。现在我有点知道如何修复它了..我将不得不尝试打开一堆套接字,其端口将在给定的端口范围内,直到我成功并将其作为第一个参数传递给 svctcp_create... 但是这个必须在 rpcgen 生成的文件中,这让我不太舒服。我想修改“.x”文件以便一劳永逸。有人可以帮我吗?谢谢, 苏尼尔

4

1 回答 1

0

Why do you need to restrict the local ports to a range? There is no support for this at any layer of the TCP networking APIs. Client port ranges are sometimes specified as firewall rules by netadmins who are unaware of the implementation infeasibility, and who think they are adding security, about which they are also mistaken. What's the reason in your case?

于 2011-05-05T12:41:10.567 回答