*BSD News Article 43952


Return to BSD News archive

Newsgroups: comp.unix.bsd.freebsd.misc
Path: sserve!newshost.anu.edu.au!harbinger.cc.monash.edu.au!simtel!zombie.ncsc.mil!news.mathworks.com!uhog.mit.edu!bloom-beacon.mit.edu!world!mv!mv.mv.com!shaman
From: shaman@mv.mv.com (Coranth Gryphon)
Subject: Re: IP address of local machine
Message-ID: <D8GwnL.384@mv.mv.com>
Nntp-Posting-Host: mv.mv.com
Sender: Coranth Gryphon <gryphon@healer.com>
Organization: MV Communications, Inc.
Date: Fri, 12 May 1995 13:40:32 GMT
References: <D8Fs2t.Cr7@mv.mv.com> <3ovkv8$ejc@huron.eel.ufl.edu>
Lines: 30

In article <3ovkv8$ejc@huron.eel.ufl.edu>,  <jfh@ucet.ufl.edu> wrote:
>
>	*( (struct in_addr *) hostEntry->h_addr_list[0] )
>
>	or easier:
>
>	struct in_addr *address = (struct in_addr *) hostEntry->h_addr_list[0];
>	inet_ntoa(*address);
>

Aftet posting, I started downloading public TCP packages to figure
out how they do it. I finally came up with much the same, though
a bit cleaner.

	struct in_addr address;

	memcpy ((char *) &address, hostEntry->h_addr_list[n], sizeof(address));

then you have a real in_addr in local memory.

-coranth

--------------------------------------------------------+----------------------
Coranth Gryphon                                         | Reality exists on a
                                                        |   need-to-know basis.
E-Mail: gryphon@healer.com, shaman@mv.mv.com            |
Pager: (603) 599-0357       Phone: (603) 598-3440       | You do not currently
US-Mail: 11 Carver Street, Nashua, NH  03060-2518       |   need to know
Disclaimer: All these words are yours, except Europa... +----------------------