2013/2/28 Roland McGrath <rol...@hack.frob.com>: > I agree they should be consistent. Note that sendto and sendmsg are > consistent with connect, rather than with bind.
I didn't know that. But I still think that the bind() behavior is better. Giving the length without NUL is traditional practice in applications. Changing bind() may cause application problems. 4.3BSD document explains as follows. doc/ps1/08.ipc/2.t of http://www.tuhs.org/Archive/4BSD/Distributions/4.3BSD/usr.tar.gz : | | #include <sys/un.h> | ... | struct sockaddr_un addr; | ... | strcpy(addr.sun_path, "/tmp/foo"); | addr.sun_family = AF_UNIX; | bind(s, (struct sockaddr *) &addr, strlen(addr.sun_path) + | sizeof (addr.sun_family)); | | Note that in determining the size of a UNIX domain address | null bytes are not counted, which is why strlen is used. 4.4BSD document also describes similar. "An Advanced 4.4BSD Interprocess Communication Tutorial" http://docs.freebsd.org/44doc/psd/21.ipc/paper.pdf sizeof (addr.sun_len) is added for 4.4BSD but the description about null bytes is not changed. POSIX is different, though. -- Tanaka Akira