Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!linus!security!genrad!grkermit!masscomp!clyde!floyd!harpo!seismo!hao!hplabs!sri-unix!mogul@shasta From: mogul%shasta@sri-unix.UUCP Newsgroups: net.unix-wizards Subject: Re: UNIX domain addressing for 4.2bsd IPC Message-ID: <14477@sri-arpa.UUCP> Date: Fri, 9-Dec-83 13:46:00 EST Article-I.D.: sri-arpa.14477 Posted: Fri Dec 9 13:46:00 1983 Date-Received: Tue, 13-Dec-83 05:48:54 EST Lines: 31 From: Jeff Mogul The primer lies, but "man 2 bind" is more truthful. You've got to #include to get the definitions for the Unix addressing domain, then create an appropriate sockaddr_un (limited to 108 bytes, not 109 bytes as the declaration would imply, because the kernel rejects sockaddrs >= MLEN and the sizeof(struct sockaddr_un) == MLEN because the compiler short-aligns it, so passing sizeof(struct sockaddr_un) as the length argument to bind() will get you an error.) By the way, don't even bother trying SOCK_DGRAM in AF_UNIX. It won't work. If you try to use sendto/recvfrom the receiver gets a totally blank address in "from". If you try to use accept() in the receiver and connect()/send() in the sender, the send() fails because it thinks you haven't yet supplied a destination address! Following connect() by sendto() fails because "you've already supplied a destination address"(!) Using sendto() by itself fails to wake up the receiver from its accept(). I spent a few days staring at the kernel sources and I think the problems with connection-based SOCK_DGRAMs (sort of a contradiction in terms anyway) might be fixed with about 4 lines of code -- but I haven't been brave enough to try it. The problems with unconnected DGRAMs are deeper, but I think it's possible to provide at least a kludgey solution. I just gave up and used AF_INET, which works more or less, but I'm not happy. -Jeff P.S.: To top it all off, there's a "man 4 inet" page but no corresponding page for the Unix domain, at least on our tape.