On Dec 06, "[EMAIL PROTECTED]" 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 [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message

Reply via email to