Date: Fri, 6 Dec 2002 11:55:30 -0800 From: Mike Hunter <mhunter@ack.Berkeley.EDU> To: dslb@tiscali.dk Cc: hackers@FreeBSD.ORG Subject: Re: accept() Message-ID: <20021206115530.A16665@ack.Berkeley.EDU> In-Reply-To: <3D9FE7F600009214@cpfe5.be.tisc.dk>; from dslb@tiscali.dk on Fri, Dec 06, 2002 at 08:50:46PM %2B0100 References: <3D9FE7F600009214@cpfe5.be.tisc.dk>
next in thread | previous in thread | raw e-mail | index | archive | help
On Dec 06, "dslb@tiscali.dk" wrote: > Hi all > > When using accept() with: > int sd_client = accept(socket_descriptor, (sockaddr *)&client, > (socklen_t *) sizeof(client)); > > Accept return -1 and 14 in errno, but when I use: > > socklen_t alen; > int sd_client = accept(socket_descriptor, (sockaddr *)&client, &alen); > > It works fine. Why can't you use the first method? There must be a way > to avoid creating a variable just to hold the address?!?!? You have to use a variable because accept may write to it (?). From the man page: The addrlen is a value-result parameter; it should initially contain the amount of space pointed to by addr; on return it will contain the actual length (in bytes) of the address returned. It doesn't make sense to cast the results of sizeof to a pointer. Mike -- Hi William. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20021206115530.A16665>