Path: utzoo!attcan!uunet!aplcen!uakari.primate.wisc.edu!ark1!oasys!mimsy!chris From: chris@mimsy.umd.edu (Chris Torek) Newsgroups: comp.unix.programmer Subject: Re: binding sockets Message-ID: <26634@mimsy.umd.edu> Date: 20 Sep 90 14:47:44 GMT References: <3580@awdprime.UUCP> Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 36 >In article <26618@mimsy.umd.edu> I wrote: >>[namelen] `should' be 2+strlen(path), or (in 4.3BSD-reno) SUN_LEN: In article <3580@awdprime.UUCP> jeffe@sandino.austin.ibm.com (Peter Jeffe 512.823.4091) writes: >Not to quibble, but it `should' be "sizeof(name.sun_family)+strlen(path)"; Not so---and I specifically wrote `2' to avoid this---because in 4.3BSD-reno the result will be one byte too short. (You must also include sizeof(name.sun_len), which is 1.) >or better yet, "sizeof(name)-sizeof(name.sun_path)+strlen(path)"; This will work, and is how SUN_LEN is defined. >in any case, assuming the 2 bytes is not a good idea. Recommendation: add the following to your code, and then use SUN_LEN. #ifndef SUN_LEN /* actual length of an initialized sockaddr_un */ #define SUN_LEN(su) \ (sizeof(*(su)) - sizeof((su)->sun_path) + strlen((su)->sun_path)) #endif > >------------------------------------------------------------------------------- >Peter Jeffe ...uunet!cs.utexas.edu!ibmaus!auschs!sandino.austin.ibm.com!jeffe > first they want a disclaimer, then they make you pee in a jar, > then they come for you in the night -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 405 2750) Domain: chris@cs.umd.edu Path: uunet!mimsy!chris