binding sockets
Chris Torek
chris at mimsy.umd.edu
Fri Sep 21 00:47:44 AEST 1990
>In article <26618 at mimsy.umd.edu> I wrote:
>>[namelen] `should' be 2+strlen(path), or (in 4.3BSD-reno) SUN_LEN:
In article <3580 at awdprime.UUCP>
jeffe at 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 at cs.umd.edu Path: uunet!mimsy!chris
More information about the Comp.unix.programmer
mailing list