*BSD News Article 52367


Return to BSD News archive

Path: euryale.cc.adfa.oz.au!newshost.anu.edu.au!harbinger.cc.monash.edu.au!simtel!news.kei.com!news.mathworks.com!tank.news.pipex.net!pipex!howland.reston.ans.net!EU.net!sun4nl!sci.kun.nl!polder.ubc.kun.nl!rhialto
From: rhialto@polder.ubc.kun.nl (Olaf Seibert)
Newsgroups: comp.unix.bsd.netbsd.misc
Subject: Re: bind()ing a socket to a specific address?
Date: 6 Oct 1995 10:26:48 GMT
Organization: University of Nijmegen, The Netherlands
Lines: 14
Message-ID: <453098$2gc@wn1.sci.kun.nl>
References: <45136o$6qf@wn1.sci.kun.nl>
NNTP-Posting-Host: polder.ubc.kun.nl
Organisation: Polderland Language & Speech Technology

In <45136o$6qf@wn1.sci.kun.nl> rhialto@polder.ubc.kun.nl (Olaf Seibert) writes:
>I am trying to bind() a socket to a specific IP address, but I always
>get the error EADDRNOTAVAIL: "Can't assign requested address".
>Nevertheless, as far as I can see, this should be possible.
>The only address that will work is INADDR_ANY (i.e., 0.0.0.0).

I have been informed that I should zero the  struct sockaddr_in first.
And indeed that does the trick. Apparently just copying the address
from gethostbyname() is not full size.

-Olaf.
--
___ Olaf 'Rhialto' Seibert      D787B44DFC896063 4CBB95A5BD1DAA96 
\X/ There are no lemurs in this post    rhialto@polder.ubc.kun.nl