Re: hostent address list dereferencing problem..

Jens.Toerring_at_physik.fu-berlin.de
Date: 01/28/05


Date: 28 Jan 2005 01:02:18 GMT

BM <b.marsh@gmx.net> wrote:
> i'm having problems grabbing the IP out of the h_addr_list (or h_addr)
> sturct on a
> freshly gethostbyname'd hostent structure.

> struct in_addr **address;

> if((h=gethostbyname(node)) == NULL) {
> herror("gethostbyname");
> exit(1);
> }

> address=(struct in_addr **)h->h_addr;

You need

  address = ( struct in_addr ** ) h->h_addr_list;

h_addr is just defined to h_addr_list[ 0 ].

> for(; *address != NULL; address++);

Here you've got a semicolon at the end of the line that definitely
shouldn't be there...

> printf("addr: %s\n",*address);

Whats pointed to by address isn't a simple string so you need

  printf( "addr = %s\n", inet_ntoa( *address );

to convert it to a string in numbers-and-dots notation.

                                    Regards, Jens

-- 
  \   Jens Thoms Toerring  ___  Jens.Toerring@physik.fu-berlin.de
   \__________________________  http://www.toerring.de


Relevant Pages

  • Re: EXCEL: How to scan text reversed (like ACCESS: InStrRev)?
    ... Not sure whether this will help, but you could use this array - ... to return each character as an array element. ... specific instance of a character in a string. ... this formula gives you the number of semicolon in the ...
    (microsoft.public.excel.worksheet.functions)
  • Re: Compensating for Bad Data
    ... I have all the string manipulation down. ... Dim rs As DAO.Recordset ... I need to leave the value alone if the two sides of the semicolon are ... compare the value before and after the semicolon-space ...
    (microsoft.public.access.externaldata)
  • Re: =?UTF-8?B?UHJvYmxlbSByZXR1cm5pbmcgaWRlbnRpdHkgZnJvbSBTUUwgU2Vy?= =?UTF-8?B?dmVyIHdoZW4gc
    ... It worked fine until I typed a semicolon into one of the string fields to be inserted. ... The string fields are inside single quotes in the INSERT command. ... With the semicolon in the string, the record is written correctly including the semicolon, but the identity is not returned. ... Dim MyCommand As SqlCommand = New SqlCommand ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Compensating for Bad Data
    ... user started an answer with a "; ") where my string manipulation was flawed. ... dim v2 as variant ... I need to leave the value alone if the two sides of the semicolon ... compare the value before and after the ...
    (microsoft.public.access.externaldata)
  • Re: Semicolon problem
    ... Dim sStr As String ... For Each cell In Selection ... If ans = vbYes Then ... > Sorry guys, when i created the thread i wanted to make the wrong> semicolon BOLD, but instead it added a * at both sides of the ...
    (microsoft.public.excel.programming)