On Sat, 3 Dec 2005, Bernd Eckenfels wrote:

On Fri, Dec 02, 2005 at 11:00:28PM -0800, Jurij Smakov wrote:
In
that case the cast from sockaddr to sockaddr_in is a problem. The sockaddr
structure consists of a short (2 bytes) and an array of 14 chars, so it is
allowed to be aligned (and is, in fact, aligned) on the 2-byte boundary,

Yes, probaly sockad should be changed to contain an array of longs instead
of chars, since it is supposed to be castable.... I really hate C :)

A somewhat cleaner solution (as pointed out by Steve again) would be to use struct sockaddr_storage instead of sockaddr, that will have the correct alignment and is guaranteed to have enough storage for both ipv4 and ipv6 sockets.

Best regards,

Jurij Smakov                                        [EMAIL PROTECTED]
Key: http://www.wooyd.org/pgpkey/                   KeyID: C99E03CC



--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to