Eclipse plugin 多播流到单播流tcl脚本问题
我开始学习tcl脚本语言,并尝试编写一个tcl脚本,将所有多播数据包通过单播网络进行隧道传输 由于我是tcl的新手,我想问以下几点:Eclipse plugin 多播流到单播流tcl脚本问题,eclipse-plugin,tcl,tk,tclsh,Eclipse Plugin,Tcl,Tk,Tclsh,我开始学习tcl脚本语言,并尝试编写一个tcl脚本,将所有多播数据包通过单播网络进行隧道传输 由于我是tcl的新手,我想问以下几点: 我正在使用Eclipse在tcl中编写代码,我已经安装了所需的插件,我认为所有的软件包也都安装了,但是Eclipse在下面的调用中强调了我 fconfigure $sockMulticast -buffering none -mcastadd $ipMulticast -translation binary -remote [list $ipMulticast $
fconfigure $sockMulticast -buffering none -mcastadd $ipMulticast -translation binary -remote [list $ipMulticast $port]
说有额外的论点,我不明白,因为它可以阅读:
Pat写道,“多播与标准单播有点不同
或广播UDP。您的操作系统将忽略多播数据包
除非应用程序已显式加入多播组
在TclUDP的情况下,我们使用
fconfigure $socket -mcastadd $mcastaddress
fconfigure
时是否应再次指定目标单播IP在第一点上,Eclipse是完全错误的。
fconfigure
命令可以使用任意数量的选项/值对(或者使用单个选项来检索值,或者不使用任何选项来一次检索多个值-虽然不一定全部;串行通道有一些奇怪的特性,但它们目前对您来说并不重要).不幸的是,他们错了,但这确实发生了
关于第二点,我不会尝试更改TCP端点的IP地址;您不能这样做(严格地说,不能使用Tcl绑定;我完全不知道您是否可以在一般情况下这样做)。TCP和UDP通道对可以更改的内容和时间有非常不同的限制(因为TCP通道使用握手协议在两个端口之间建立连接的会话,而UDP根本没有此类限制;反过来,TCP通道可以被视为可靠的流,而UDP根本不是流协议,没有会话/连接)
您的
lappend
调用也有问题;您忽略了变量名和要附加到这些全局列表的值之间的一个关键空格。这意味着您希望保存连接信息列表的全局变量实际上不会这样做;相反,您会得到许多奇怪的变量这完全是不切实际的名称。如果您添加IPv6支持,它将完全崩溃(因为它可以在呈现IP地址时使用:
,尽管它也是Tcl名称空间分隔符)。现在解决它;在将来为自己省去一点麻烦…通常建议您每个问题只问一个问题;这样更容易获得搜索功能。我应该警告,我不会在自己的项目中使用TclUDP;我通常不需要。(这些项目的运行方向与您的方向非常不同…)好的,我不会注意eclipse语法和fconfigure…关于第二点,我如何将多播通信量隧道到单播通信量?例如,我应该始终使用UDP吗?我的意思是,通过UDP单播套接字隧道UDP多播通信量,这是一个更好的选择吗?
#!/bin/sh
# updToTcp.tcl \
exec tclsh "$0" ${1+"$@"}
package require udp
set ::connectionsMulticast [list]
set ::connectionsUnicast [list]
proc udp_connect {ipMulticast ipUnicast port {multicast false}} {
#Open UDP multicast socket
set sockMulticast [udp_open $port]
if {$multicast} {
#configures the multicast port
fconfigure $sockMulticast -buffering none -mcastadd $ipMulticast -translation binary -remote [list $ipMulticast $port] ;#(1)
#update the list of multicast connections with the socket
lappend ::connectionsMulticast[list $ipMulticast $port $socketMulticast]
#Open TCP unicast socket
set sockUnicast [socket $ipUnicast $port]
#configures the unicast port
fconfigure $sockUnicast -buffering none -translation binary;#(2)
#update the list of unicast connections with the socket
lappend ::connectionsMulticast[list $ipUnicast $port $socketUnicast]
#listen to the multicast socket, and forwarding the data to the unicast one
fileevent $sockMulticast readable [list ::dataForwarding $sockMulticast $sockUnicast]
}
}
proc dataForwarding {socketSrc socketDst} {
#get the data from the source socket, and place it on data
set data [read $socketSrc]
#placing the data in the destination socket
puts -nonewline $socketDst $data
return
}