akohan
asked on
Question on gethostbyname() function
Hello group,
I'm new to socket programming in C (Linux) and currently trying to retrieve a page which works fine as long as there argument is only something like www.example.com but for instance if I pass:
myprog www.example.com
the code returns the html page contents and all tags ...
but if I use it as
myprog www.example.com/corporate/aboutus.php
It won't work if I add a / or page at the end of it. Any idea why?
Your help is appreciated.
Regards.
It seems in new IPv6 I should use getaddrinfo() but since I'm using somebody's else code so don't want to change it too much.
I'm new to socket programming in C (Linux) and currently trying to retrieve a page which works fine as long as there argument is only something like www.example.com but for instance if I pass:
myprog www.example.com
the code returns the html page contents and all tags ...
but if I use it as
myprog www.example.com/corporate/aboutus.php
It won't work if I add a / or page at the end of it. Any idea why?
Your help is appreciated.
Regards.
It seems in new IPv6 I should use getaddrinfo() but since I'm using somebody's else code so don't want to change it too much.
gethostbyname is trying to resolve an ip address for the host itself. in your second instance you are passing a full url which cannot be resolved through a dns.
ASKER
Thanks! now what approach should I take to return an sub page or a page from a server?
Regards.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Yes, that should be it.
Thanks!