Resolve local addresses

  • Follow


I am writing a small webserver application in c and i wondered if i
could translate local addresses like "imac-dev.local" to a valid
sockaddr structure. I don't know if these addresses are used only on
Mac OS X, but i would like it to be as portable as possible (except for
windows), if this is the OS X style of local addresses, could someone
explain me how it is done in other *nixes ? I know about /etc/hosts but
i think there must be a better way. Any help is appreciated.

0
Reply ruben.de.visscher (9) 2/1/2006 4:06:00 PM

Hi Ruben,

gethostbyname() is your friend.

Regards ... Rainer
0
Reply Rainer 2/1/2006 5:17:26 PM


>I am writing a small webserver application in c and i wondered if i
>could translate local addresses like "imac-dev.local" to a valid
>sockaddr structure. 

Use the same method you use for non-local addresses:  gethostbyname().
Put the local names in DNS or /etc/hosts.

>I don't know if these addresses are used only on
>Mac OS X, but i would like it to be as portable as possible (except for
>windows), if this is the OS X style of local addresses, could someone
>explain me how it is done in other *nixes ? I know about /etc/hosts but
>i think there must be a better way. Any help is appreciated.

						Gordon L. Burditt
0
Reply gordonb 2/1/2006 6:27:47 PM

Gordon Burditt wrote:
>> I am writing a small webserver application in c and i wondered if i
>> could translate local addresses like "imac-dev.local" to a valid
>> sockaddr structure. 
> 
> Use the same method you use for non-local addresses:  gethostbyname().
> Put the local names in DNS or /etc/hosts.

Or, on Mac OS X, it might go into NetInfo instead.  (I'm going to guess
that's where stuff like imac-dev.local is stored.)

   - Logan
0
Reply Logan 2/2/2006 1:33:33 AM

Okay thanks! I got it to work now.

0
Reply ruben 2/4/2006 10:09:54 AM

4 Replies
115 Views

(page loaded in 2.016 seconds)

Similiar Articles:













7/18/2012 12:05:43 PM


Reply: