ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
gethostbyname() returns a structure and member of this structure is of type char **h_addr_list.So basicly h_add_list should point to an array of pointers to char.
Instead it points to an aray of pointers to struct in_addr.
How can this even work and why didn't the designers made h_addr_list of type struct in_addr **h_addr_list?
I think struct in_addr is used to hold the IP address.
U pass ip address as a string . Is it right?
If its correct , They used char ** to support for maintanance (or portability) of previous code, because this IP address size (IPv6 new address) will change as the network grows. So they might have used it instead of that struct. When we use char **. we can get the full address regardless of its size(taking \0 as the last character).
I know very little. it may be correct or wrong. Dont scold me if its wrong.
if you look at the definition of struct in_addr (from netinet/in.h) you will see that the struct only has 1 member which is a 32bit unsigned integer which could be treated as 4 bytes or chars. so thats why it works, as for why they did it - i dont know as my network programming knowledge is quite limited.