closing the filedescriptor just removes one reference to the channel
from the descriptor table. the kernels read() function takes its
own reference to the channel to make sure it doesnt go away under it.

the method you describe is a anti-pattern. because the filedescript
(slot) can be reallocated. so even if you close it in the proc, the
fd slot could be reused for somthing different before the other proc
comes arround reading it (or worse, writing it).

what you want is to hangup the tcp connection without fiddling with
the filedescriptor table. this can be done by writing "hangup" to the
connections ctl file like:

int fd, cfd;

fd = dial("tcp!....!123", nil, nil, &cfd);

.....


hangup(cfd);    /* hangup connection, fd stays valid but i/o will error */

--
cinap

Reply via email to