Rebol 2端口绑定到多个IP

Rebol 2 port binding to multiple IPs

我有一个具有多个 IP 的 Windows 设置,并希望我的 Rebol 脚本(在 Rebol/Core 2.78 上)进行单独绑定并在每个 IP 上监听相同的端口号。

直到最近我还认为这样做的语法是:

Port1Test: open/lines tcp://:80   browse http://10.100.44.6?
Port2Test: open/lines tcp://:80   browse http://10.100.44.7?

但结果是 Port2Test 行失败了,因为 browse http://10.100.44.6? 部分被完全忽略了(现在正在搜索,我什至无法找到我最初从哪里获得该语法的位置) .
阅读文档,我可以找到关于如何指定监听端口的所有内容,如下所示:

Port1Test: open/lines tcp://:80

探测 Port1Test 端口显示大多数设置设置为 none,一些设置如下:

scheme: 'tcp
host: none
port-id: 80
local-ip: 0.0.0.0
local-port: 80

所以我尝试像这样修改这些值:

Port1Test: open/lines tcp://:80  ; Create port, as before. Then modify below
Port1Test/host: 10.100.44.6      ; Might this be the binding interface?
Port1Test/port-id: 1             ; I guess this is just an id?
Port1Test/local-ip: 10.100.44.6  ; This ought to be the binding interface.

Port2Test: open/lines tcp://:80  ; Create port, as before. Then modify below
Port2Test/host: 10.100.44.7      ; Might this be the binding interface?
Port2Test/port-id: 2             ; I guess this is just an id?
Port2Test/local-ip: 10.100.44.7  ; This ought to be the binding interface.

不幸的是,上述修改的所有变体,包括交换 Port1TestPort2Test 的 IP 值,在创建 Port2Test 时都失败了。 :-(

我确定我忽略了一些东西,但我找不到任何关于如何在将端口绑定到特定接口时初始化端口的提示。

非常感谢任何提示!


编辑: Rebol 绑定到接口的方式现在对我来说已经很明显了——但是如何修改它仍然是个谜。

假设我有两个 IP(== 接口)关联到一张网卡:10.100.1.1 和 10.100.1.2。 在 10.100.1.1:80 上,我设置了一个 Tomcat 应用程序,我知道它可以绑定到该特定接口。 然后我启动一个 REBOL 应用程序,它也声明了端口 80。 它们都 运行 愉快,并且每个都只能在一个 IP 上访问,就好像 Rebol 应用程序绑定到 10.100.1.2 一样。 然后我关闭 Tomcat 应用程序,并尝试启动它。事实证明这是不可能的,因为接口正在使用中。 如果我访问这两个 IP,则结果表明 Rebol 应用程序可以在两个 IP 上访问。

这不是 Rebol 中的主动机制在这里起作用,而是因为 Rebol 声明了 0.0.0.0 接口(在服务器的上下文中,0.0.0.0 意味着 "all IPv4 addresses on the local machine"),它被转换为任何当前可用的接口,以及接口可用时的延迟声明。

如果能知道如何在创建端口时将 Rebols 默认接口 0.0.0.0 更改为其他接口,那就太好了!

Rebol2 侦听端口默认绑定到所有可用的 IPv4 接口 (0.0.0.0),据我所知,不幸的是,没有办法改变它。

仅供参考,Rebol2 使用 interfaces 端口模式公开现有的 IPv4 接口:

>> p: open tcp://:8000
>> probe get-modes p 'interfaces
[make object! [
        name: "if19"
        addr: 10.27.10.110
        netmask: 255.255.255.252
        broadcast: 10.27.10.111
        dest-addr: none
        flags: [broadcast multicast]
    ] make object! [
        name: "lo0"
        addr: 127.0.0.1
        netmask: 255.0.0.0
        broadcast: none
        dest-addr: none
        flags: [multicast loopback]
    ] make object! [
        name: "if16"
        addr: 192.168.1.4
        netmask: 255.255.255.0
        broadcast: 192.168.1.255
        dest-addr: none
        flags: [broadcast multicast]
    ]]

唉,这是只读的...(文档说不可设置)。

您可以找到所有端口模式的列表here,希望对您有帮助。