Link to home
Start Free TrialLog in
Avatar of akohan
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.



Avatar of sweetfa2
sweetfa2
Flag of Australia image

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.
Avatar of akohan
akohan

ASKER



Thanks! now what approach should I take to return an sub page or a page from a server?

Regards.
ASKER CERTIFIED SOLUTION
Avatar of sweetfa2
sweetfa2
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of akohan

ASKER



Yes, that should be it.

Thanks!