Work as in triggering?fileevent readable NEVER works and fileevent writable ALWAYS works- even if the conneection isn't!
This requires an understanding of when a channel is considered readable or writable. To quote the fileevent manpage:
As I stated in my previous post, you leave the writable event going, which means it'll trigger over and over and ... I thought I mentioned that writable also includes error conditions, but I guess I missed it. Nevertheless my code handles it.A channel is considered to be readable if there is unread data available on the underlying device. A channel is also considered to be readable if there is unread data in an input buffer, except in the special case where the most recent attempt to read from the channel was a gets call that could not find a complete line in the input buffer. This feature allows a file to be read a line at a time in nonblocking mode using events. A channel is also considered to be readable if an end of file or error condition is present on the underlying file or device. It is important for script to check for these conditions and handle them appropriately; for example, if there is no special check for end of file, an infinite loop may occur where script reads no data, returns, and is immediately invoked again.
A channel is considered to be writable if at least one byte of data can be written to the underlying file or device without blocking, or if an error condition is present on the underlying file or device.
As you fail to close the socket, should any error condition arise, the socket will remain writable. Since your proc never raises an error condition, fileevent will never drop the event handler by it's own either. Hence you get an infinite loop. But that, I already mentioned in my previous post...
Oh, and if I was not clear enough, the reason for your 5min freeze in that other post.. this is the very line that causes it:
Code: Select all
while {(![eof $PlaySock])} {set PlayInfo [gets $PlaySock];}