tclsh中的事件支持没有tkcon中好

【关键字】 tclsh tkcon socket fileevent

1,在学习socket 的时候,发现在tkcon中正常运行的程序,在tclsh中不能正常运行后来发现,一些回调函数在tclsh中不能够正确的运行如,socekt -server callback,这里的callback不能够执行,还有针对于socket的注册的一些fileevent不能够很好的执行。

2,解决在注册事件后,vwait forever来等待事件的发生就可以执行。

 

--- 2011-0514 -更正一下

原来不是支持的好不好的问题,就是不支持,在doc中讲述after 命令的时候有这么一句话:

tclsh 不是事件驱动的 写道
The after ms and after idle forms of the command assume that the application is event driven: the delayed commands will not be executed unless the application enters the event loop. In applications that are not normally event-driven, such as tclsh, the event loop can be entered with the vwait and update commands.

 所以才有上面的问题,after和fileevent都是一样的注册事件的。

能够用after 2000 {puts xxx};puts yyy这个命令很好的测试这个,在tkcon中yyy先输出,随后xxx输出;而在tclsh中yyy输出,等好久xxx也不会输出,知道你输入vwait 或者update。

你可能感兴趣的:(socket)