2013-08-23 45 views

回答

4

您可以通過在客戶端port!上調用QUERY來獲取該信息,該查詢將返回一個包含remote-ipremote-port字段的對象。

這裏的說明這一點,用一個簡單的服務,監聽端口9090連接和打印連接到服務端的地址一個簡單的例子:

rebol [] 

awake-server: func [event /local client info] [ 
    if event/type = 'accept [ 
     client: first event/port 
     info: query client 
     print ajoin ["Client connected: " info/remote-ip ":" info/remote-port] 
     close client 
    ] 
] 

serve: func [endpoint /local listen-port] [ 
    listen-port: open endpoint 
    listen-port/awake: :awake-server 
    wait listen-port 
] 

serve tcp://:9090 
1

system/standard/net-info對象包含兩個值 - local-ip和remote-ip。我不確定他們是否得到確定。

給system/standard/net-info/remote-ip一個試試看,如果它不包含,我會建議提交一個bug報告。

相關問題