[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: LuaSocket - how can a tcp client detect a closed connection?
- From: Dave Dodge <dododge@...>
- Date: Sat, 3 Mar 2007 22:33:22 -0500
On Sat, Mar 03, 2007 at 06:31:37AM -0800, Taj Khattra wrote:
> >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.
No, you _need_ two if you want to compare them meaningfully to
traditional Unix pipes. By making use of bidirectional communication
through a socket, you are taking advantage of an additional feature
that sockets offer over pipes, and you should not be surprised that
using this extra functionality breaks the similarity with the behavior
of a pipe.
If you want sockets to behave like pipes, then use them
unidirectionally like pipes. And if you want pipes to behave like
sockets, you can get something pretty close by using socketpair()
instead of pipe() to create them.
It should be noted that in SVR4 UNIX, regular pipes actually _are_
bidirectional. For example all pipes on Solaris are bidirectional,
and on IRIX you can request them at link time. Of course just as with
sockets, any application making use of this bidirectionality will need
to be redesigned if you want to run it on a system with the more
traditional unidirectional pipes.
-Dave Dodge