[fpc-pascal]getting my local ip

Michael Van Canneyt michael.vancanneyt at wisa.be
Fri Mar 15 09:36:00 CET 2002


On Thu, 14 Mar 2002, ron wilson wrote:

> im having difficulty getting my ip from within a winsock program.  this is
> mainly due to my inability to understand this:
>
>     type
>        hostent = record
>           { official name of host  }
>           h_name: pchar;
>           { alias list  }
>           h_aliases: ^pchar;
>           { host address type  }
>           h_addrtype: SmallInt;
>           { length of address  }
>           h_length: SmallInt;
>           { list of addresses  }
>           case byte of
>              0: (h_addr_list: ^pchar);
>              1: (h_addr: ^pchar)
>        end;
>
> how do i understand the case statement?  what does 'case byte of' refer to?
> in all the c examples i have read, they indicate that h_addr_list should
> contain an array of addresses for the host, i.e. me.  however, the length of
> this list is always 4 bytes, which is only one address, and it's always the
> same as h_addr, both pointing to the loopback address.  the c examples all
> use h_addr_list as an array.  why isn't this an array here?  im seriously
> confused.

It is not an array here because it is not a real array; It's just a
pointer to a null-terminated list of names.

The h_addr_list and h_addr pointers can be used interchangably. Probably
a name change occurred, and for compatibility reasons both names have
been retained.

Michael.





More information about the fpc-pascal mailing list