lua-users home
lua-l archive

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


There are TWO pipes here

yes, a pipe is unidirectional, so i need two.

and only ONE tcp connection here.

yes, a tcp connection is bidirectional, so i need just one.

Or use ssh:

i can't see why ssh decided to make an appearance here, unless it's
specific to the example i gave.  there's no tcp ofile being shared in
your pipeline, so it doesn't address the "TCP FIN after last writer
leaves" issue.  or are you suggesting that a tcp socket should always
be restricted to a single local process (in this case, ssh)?

DJB wishes sockets were defined like unix pipes, unidirectional, but
instead they are designed like unix ttys and unix files, bidirectional.

it's about readers and writers, not unidirectional vs. bidirectional.

a pipe has separate read and write fds because it has readers and
writers, not because it's unidirectional.  the kernel knows when the
last writer leaves, and can subsequently signal an eof to the readers
(and vice versa, when the last reader leaves).  a tty/file doesn't
have the same requirement.

a tcp socket also has readers and writers, and the kernel should,
without being prodded, signal an eof (TCP FIN to its tcp peer) after
the last local writer leaves.  seems more like a pipe than a tty/file.

and yes, i know it's too late to change the socket api now and am not
suggesting that we go and break all the code out there for the sake of
"uniformity".

I haven't used luasocket, but

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

doesn't work as advertised?

sure it does.  but i can't also shutdown() an arbitrary fd.  since
luasocket already has a binding to shutdown() i was hoping that i
could.  but it seems like the low-level binding isn't being exposed.
or maybe i didn't look close enough.