On 01/06 08:56, Ted Unangst wrote:
> On Thu, Jan 6, 2011 at 7:19 PM, Jeremy Evans <jer...@openbsd.org> wrote:
> > I believe that for unix stream sockets, you don't need to have a sending
> > socket file created, while you do for datagram sockets, as otherwise you
> > can't have a bidirectional connection.
> >
> > I have no problem with always using a random sending socket file, and
> > ignoring -p in the unix datagram case, if you think that is best.
> > Thinking more about it, -s would be more appropriate than -p anyway if
> > you did want to specify the source socket.
> 
> The part that's confusing me is, who is at the other end of this tmp
> socket?  How do they know about it?

With a stream socket where you are acting as a client, you don't need a
temporary socket created, because a stream socket is bidirectional. If
you send a datagram to a server listening on a unix datagram socket,
there is no way for the server program to respond to you unless the
sending program is also bound to a socket.

So with this patch, if you are operating nc in client mode and
sending a datagram to a unix datagram socket, nc binds a temporary
unix datagram socket so that you can receive responses.

guenther@ agreed back in 2008 that it was necessary to create a
temporary socket if you want bidirectional communication, see
http://marc.info/?l=openbsd-tech&m=120299257422367&w=2.  He also
mentioned that it might be beneficial to implement two modes, one
providing bidirectional and one providing unidirectional, but I have
not implemented that (yet).

Jeremy

Reply via email to