|
On Mar 5, 2007, at 9:38 AM, gary ng wrote:
So if you send some information you'd get code like: fd:write(data) fd:shutdown("send") .... fd:read() This will allow you to read incoming data after you have sent all there is to send. Doing a 'dup2' creates another file descriptor, but this descriptor does not differ in any way from the original one. The underlying software (e.g. the network stack or file system) will only be notified of a 'close' when all file descriptors pointing to the same file/socket have been closed. So 'shutdown' is still necessary. Daniel Bernstein's observation was that if the socket interfaces would have returned 2 file descriptors instead of one 'close' could have done the job, and software could have been oblivious of the differences between pipes, files and sockets. He's not alone in thinking that. See Rob Pike's presentation: http://herpolhode.com/rob/ugly.pdf. I'm not so sure than porting the BSD socket interface to all kinds of other OSes and languages was such a good idea. Gé -- Gé Weijers |