飞鸽(IPMSG)在企业局域网内应用还是非常广泛的,我本来想用ruby写个程序可以与之交互,网上一番搜索,发现一日本程序员已经实现了一个ruby版的,略改一下,测试效果不错(原文参见:[url]http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-list/10343[/url]):
require "socket"
class IPMSG
IPMSG_PORT = 2425
VERSION = "1"
COMMAND = "32" #send msg
def initialize(user, port = IPMSG_PORT)
@user = user
@port = port
@sock = UDPsocket.new
end
def send(target, msg)
s = [VERSION,rand(100),target,@user,COMMAND,msg].join(":")
puts s
@sock.connect target, @port
@sock.send s, 0
end
end
#----------------------------------------------------------------
ipmsg = IPMSG.new("dyw")
ipmsg.send "10.4.45.65","hi,ruby ipmsg test 中文"