lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lwip-users] Question about a specific error handling in "lwip_sendt


From: Simon Goldschmidt
Subject: Re: [lwip-users] Question about a specific error handling in "lwip_sendto" (1.4.0.rc1)
Date: Wed, 20 Oct 2010 16:24:29 +0200

"Benjamin Schelte" <address@hidden> wrote:
> So LWIP_ERROR will throw an error here, because (sizeof(struct sockaddr))
> !=
> (sizeof(struct sockaddr_in)).

That seems like a bug in our "struct sockaddr" definition. I though the two 
structs have the same size...?

> Is this intended behavior?

Yes: 'struct sockaddr' is like an "abstract base-class" struct: it is not 
really useful on its own, only the derived structs are used. However, this was 
the way the creators of the BSD socket API wanted to create functions that 
don't change for future addresses. As the lwIP socket API only supports IPv4 
addresses, you have to pass a sockaddr_in. Passing a sockaddr is *not* correct! 
You have to pass a struct sockaddr_in casted to a "struct sockaddr*", but the 
size has to be "sizeof(struct sockaddr_in)".

> Or is either the LWIP_ERROR condition or the parameter list of lwIP_sendto 
> incorrect?

See above. After all, since the two sizes should be the same, you wouldn't have 
noticed that your code is wrong ;-) It might work, but it's not how it is 
intended.

Simon
-- 
GRATIS! Movie-FLAT mit über 300 Videos. 
Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome



reply via email to

[Prev in Thread] Current Thread [Next in Thread]