Xref: utzoo alt.sys.sun:4084 comp.unix.wizards:25832 Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!thunder.mcrcim.mcgill.edu!mouse From: mouse@thunder.mcrcim.mcgill.edu (der Mouse) Newsgroups: alt.sys.sun,comp.unix.wizards Subject: Re: Maybe I am missing something....but why doesn't this work? Keywords: TCP SOCKETS Message-ID: <1991Jun1.193159.24881@thunder.mcrcim.mcgill.edu> Date: 1 Jun 91 19:31:59 GMT References: <1991May29.145535.23801@bradley.bradley.edu> Organization: McGill Research Centre for Intelligent Machines Lines: 33 In article <1991May29.145535.23801@bradley.bradley.edu>, brad@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@larry.mcrcim.mcgill.edu