Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.2 9/17/84; site opus.UUCP
Path: utzoo!watmath!clyde!bonnie!akgua!whuxlm!harpo!decvax!genrad!panda!talcott!harvard!seismo!hao!nbires!opus!mccallum
From: mccallum@opus.UUCP (Doug McCallum)
Newsgroups: net.unix
Subject: Re: AF_INET sockets, code examples needed.
Message-ID: <1264@opus.UUCP>
Date: Sun, 30-Jun-85 23:04:25 EDT
Article-I.D.: opus.1264
Posted: Sun Jun 30 23:04:25 1985
Date-Received: Fri, 5-Jul-85 03:10:40 EDT
References: <240@greipa.UUCP> <1004@wucs.UUCP>
Organization: NBI,Inc, Boulder CO
Lines: 16

> My code never works unless I bind a name to the client's socket.
> 
> Actually, this is not surprising, because a name is required.
> 
> Here is part of the code I use to bind a name to a socket:
> 
> 	do {
>                 sin_sync.sin_port = htons( (--portnum));
>         } while( 
> 	     bind( sock_num, (char *)&sin_sync, sizeof(sin_sync) ) < 0
> 	   &&

Actually, setting the port  to zero works as a wildcard.  The bind  will
then select the next free port number available.  The only time something
like  this code sample is needed is if the portnumber desired is in
the priviledged range ( <1024 ).