Re: serving a file to a client --- background fcopy read fileevent event puts socket channel blocking nonblocking



Thanks everyone for your replies. It is very enlightening.

I read the manual for fcopy and duplicated the second example exactly
as it is on the page and it worked.
I was trying to run my previous code like this (simplified}:

set check 1
while {$check} {
fcopy $in $out -command [list CopyMore $in $out] -size 1024
}

proc CopyMore {in out args} {
if {[eof $in]} {set check 0; close $in}
}

I thought that it worked the way "read" command works, by reading from
where it left of but instead I was getting a "file busy" error.
I am still not sure why my code did not work.

I was able to simulate fcopy with TCL commands by using variable
trace. And it was a very good exercise. :)
.



Relevant Pages