lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On 3/1/07, Sam Roberts <sroberts@bycast.com> wrote:
doing a close() works fine, you can do as he describes without trouble.

nope, it doesn't work.

here's a (useless) pipeline:
   % echo howdy | cat | cat
   howdy
   %

works as expected.  now let's make the middle cat a tcp service:
   % tcpserver -RHl0 0 6969 sh -c 'exec cat' &

let's try our pipeline again, this time using the cat tcp service:
   % tcpclient -RHl0 0 6969 sh -c ' echo howdy >&7 & exec cat <&6'
   howdy
   <waiting... still waiting... hmm... looks like we are stuck>

here comes the "device specific garbage" to the rescue :), where the
"device" in this case is tcp:
   % echo 'main() { shutdown(1, 1); }' >tcpfin.c
   % cc -o tcpfin tcpfin.c
   % tcpclient -RHl0 0 6969 sh -c '(echo howdy; ./tcpfin) >&7 & exec cat <&6'
   howdy
   %

works, but it's unfortunate that we have to stick that tcp specific
crud in there.  having separate read and write ofiles, just like pipes
do, would obviate the crud.

to stay at least partly on-topic for lua-l:  it seems like i can't
write tcpfin using luasocket, which just doesn't seem right...