Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 09 Sep 2012 15:43:42 -0400
From:      Sam Varshavchik <mrsam@courier-mta.com>
To:        freebsd-questions@freebsd.org
Subject:   How to detect unconnected AF_UNIX sockets
Message-ID:  <cone.1347219822.563023.17725.1000@monster.email-scan.com>

next in thread | raw e-mail | index | archive | help
This is a MIME GnuPG-signed message.  If you see this text, it means that
your E-mail or Usenet software does not support MIME signed messages.
The Internet standard for MIME PGP messages, RFC 2015, was published in 1996.
To open this message correctly you will need to install E-mail or Usenet
software that supports modern Internet standards.

--=_monster.email-scan.com-17725-1347219822-0003
Content-Type: text/plain; format=flowed; delsp=yes; charset="UTF-8"
Content-Disposition: inline
Content-Transfer-Encoding: 7bit

I'm porting existing code from Linux where a connect() to an AF_UNIX socket  
that exists, but does not have a listener, fails with ECONNREFUSED. This is  
quite agreeable with the comparable scenario in AF_INET, with a connection  
attempt to a port without a listener on it. So the same code handles both  
situations, immediately reporting an error, and without caring much about  
the type of the socket.

But on FreeBSD, according to truss, it seems that a connect() to an AF_UNIX  
socket without a listener still succeeds. A subsequent write() also  
succeeds, and read() blocks.

The fall-out is quite unfortunate, and I was hoping for a way to detect that  
my allegedly connected socket is lying to me, and it's not really connected  
to anything. How would I go about doing that? I tried using the  
LOCAL_CONNWAIT option as documented in unix(4), but that does not appear to  
make any difference, in this situation.


--=_monster.email-scan.com-17725-1347219822-0003
Content-Type: application/pgp-signature
Content-Transfer-Encoding: 7bit

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)

iEYEABECAAYFAlBM8W4ACgkQx9p3GYHlUOIbZgCeKBKMVKMOApXOkIb2R0eY6zWM
sv4An0sJM2aIYhXOgEZ30FuIuN+gMDH5
=H0nQ
-----END PGP SIGNATURE-----

--=_monster.email-scan.com-17725-1347219822-0003--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?cone.1347219822.563023.17725.1000>