
23 Oct
2010
23 Oct
'10
9:04 p.m.
Michael Snoyman
This does seem like the right approach. Just as fair warning: using an enumerator for serving files loses out on the possible optimization of a sendfile system call. Another possibility may be to keep a pool of file names to use as temporary files and keep rotating their usage. But I *do* think your approach is the correct one.
On unixy systems the "correct" approach traditionally would be to open
the file, then unlink it before you send the data out the socket. When
the file descriptor is closed, the link count goes to zero and the file
goes away. Obviously this isn't portable though.
G
--
Gregory Collins