lua-users home
lua-l archive

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


On Fri, Mar 02, 2007 at 12:47:36AM -0800, Taj Khattra wrote:
> 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.

Ah, I missed the "doesn't work with ucspi" part.

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

There are TWO pipes here

> 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

and only ONE tcp connection here. To make this the same, you would need
a hypothetical utility that worked like:

% tcp --read 9002 "cat"
% tcp --read 9001 --write localhost:9002 "cat"
% tcp --write localhost:9001

This would result in:

  echo howdy {tcp link} cat {tcplink} cat


Or use ssh:

sroberts@pebble:~% echo howdy | /usr/bin/ssh root@192.168.130.11 cat | cat
howdy
sroberts@pebble:~%

DJB wishes sockets were defined like unix pipes, unidirectional, but
instead they are designed like unix ttys and unix files, bidirectional.
Making them more like pipes would make them less like files and ttys, so
ucspi would work work better, and many other things would work worse.

Making things more uniform in unix would take a lot more work than a
tweak to the BSD socket API, and then it wouldn't be unix, it would be
plan9.

> 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...

I haven't used luasocket, but

http://www.cs.princeton.edu/~diego/professional/luasocket/tcp.html#shutdown

doesn't work as advertised?

Sam