Path: utzoo!attcan!uunet!know!samsung!dali.cs.montana.edu!uakari.primate.wisc.edu!aplcen!haven!mimsy!chris From: chris@mimsy.umd.edu (Chris Torek) Newsgroups: comp.unix.programmer Subject: Re: binding sockets Message-ID: <26618@mimsy.umd.edu> Date: 19 Sep 90 12:55:43 GMT References: <1990Sep16.183730.18698@athena.mit.edu> Distribution: comp Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 22 In article <1990Sep16.183730.18698@athena.mit.edu> jik@athena.mit.edu (Jonathan I. Kamens) writes: > No, actually, the namelen parameter one passes to bind() should be the >sizeof the sockaddr structure being passed into it ... Well, it `should' be 2+strlen(path), or (in 4.3BSD-reno) SUN_LEN: > name.sun_family = AF_UNIX; > strcpy(name.sun_path, "/tmp/testsocket"); > bind(s, &name, sizeof(name)); bind(s, &name, SUN_LEN(name)); Since the size of a sockaddr_un is carefully set to fill one mbuf, using sizeof(name) will work, and you can `cheat' and just use sizeof(name): the embedded '\0' will (must) be within the resulting single mbuf allocated by the bind() system call and the name lookup will work. But the documentation (such as it is) says that the name length `should' be exactly right, and a future version of the system might require this. -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 405 2750) Domain: chris@cs.umd.edu Path: uunet!mimsy!chris