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

本文探讨了Tcl编程语言中tclsh与tkcon解释器环境下socket和fileevent行为的不同,特别是在事件驱动方面的差异,并提出了通过vwait和update命令进入事件循环的解决方案。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

【关键字】 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。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值