Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 13 Feb 1996 11:38:43 +0100
From:      Andres Vega Garcia <Andres.Vega_Garcia@sophia.inria.fr>
To:        questions@FreeBSD.ORG
Subject:   Re: Q: programming sockets source address? 
Message-ID:  <199602131038.LAA02981@fun.inria.fr>
In-Reply-To: your message of Mon, 12 Feb 1996 20:07:18 PST.

next in thread | raw e-mail | index | archive | help
: Terry Braun <tab@talking.com> wrote:
  
>
>Your message dated: Mon, 12 Feb 1996 17:40:46 PST
>>
>>> So far, my initial attempts to use bind() before connect() have 
been a 
>>> wash, as bind returns an errno of EADDRNOTAVAIL, regardless of 
which 
>>> address I'm using.  I was under the impression that bind could be 
used 
>>> before a connect to set the source address.  Is this wrong?  Is 
there a 
>>> correct way to do this (needs to be portable to Linux)?
>>
>I'm not sure what you are trying to do, but if you want to listen on
>a particular socket on you local machine, say on port 1520, this code
>will work-
>
>       bindname.sin_addr.s_addr = htonl(INADDR_ANY);
>	bindname.sin_family = AF_INET;
>	bindname.sin_port = htons(1520);
>	n = bind(sock, &bindname, sizeof(bindname));
>\t
>--------
>Terry Braun                  tab@talking.com
>Talking Networks, Inc.       510-525-6696

	And what can I do to select an specific  interface (provided I have 
several interfaces)?. Do I just pass the addres belonging to the 
interface selected (bindname.sin_addr.s_addr = htonl(my_interface's_ad
dr);) ?

	Thank you.

Andres

------------------------------
INRIA Sophia-Antipolis, France
      avega@fun.inria.fr




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199602131038.LAA02981>