tech-net archive

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

struct sockaddr_storage issues



Hi, I'm seeing issues on NetBSD where connect() returns error and sets
errno to "Invalid argument". Below is a fragment of code that causes
this:

struct sockaddr_storage addr
...
fd = socket(addr.ss_family, SOCK_STREAM, 0)
connect(fd, (struct sockaddr *)&addr, sizeof(addr))

If I replace the above connect() with

connect(fd, (struct sockaddr *)&addr, sizeof(struct sockaddr))

then connect() succeeds. Looks like NetBSD is not happy about the size
of struct sockaddr_storage. On Linux this works correctly.

sizeof(struct sockaddr)=16
sizeof(struct sockaddr_storage)=128

Is this a NetBSD specific bug, or am I not using sockaddr_storage
correctly?

I'm not subscribed to the list, please CC me when replying.

Thanks.



Home | Main Index | Thread Index | Old Index