Maybe I am missing something....but why doesn't this work?
der Mouse
mouse at thunder.mcrcim.mcgill.edu
Sun Jun 2 05:31:59 AEST 1991
In article <1991May29.145535.23801 at bradley.bradley.edu>, brad at bradley.bradley.edu (Bradley E. Smith) writes:
> I am not sure why but the following program has problems.....
[program deleted - problem with bind()]
> HARDWARE USED:
> SUN 470 SunOS 4.1.1 - NO
> SUN SLC SunOS 4.1.1 - NO
> IBM RT BSD OS - YES
> AT&T 3B2 WIN TCP 3.2 - YES
> AT&T 386 WIN TCP 3.0 - YES
What you need to do is zero the supposedly-unused area of the struct
sockaddr_in before calling bind(). As far as I know SunOS is the only
system that imposes this requirement, but the range of systems I have
actually checked this on is fairly small - 4.3 BSD is the only one that
I'm sure doesn't require it.
Try doing a bzero((char *)&backupserver,sizeof(backupserver)) before
storing anything into it. That generally does it for me.
The reason calling x() changes things is that backupserver (which is an
auto variable) is allocated at a slightly different place on the stack,
so the unused portion contains different stack trash. The working way
places it so the unused portion contains zeros.
der Mouse
old: mcgill-vision!mouse
new: mouse at larry.mcrcim.mcgill.edu
More information about the Comp.unix.wizards
mailing list