Re: [newbie] specify address in various formats?
Re: [newbie] specify address in various formats?
- Subject: Re: [newbie] specify address in various formats?
- From: "Justin C. Walker" <email@hidden>
- Date: Sat, 24 May 2003 12:36:49 -0700
On Saturday, May 24, 2003, at 12:19 PM, Sebastian Mecklenburg wrote:
On Saturday, May 24, 2003, at 08:20 PM, Sebastian Mecklenburg wrote:
hello,
i want to program a simple tcp-client (using unix sockets) where the
user should be able to specify the servers address either as ipv6
address ("fe80::1"), ipv4 address ("127.0.0.1") or as name-string
("localhost" or "www.whatever.org"). how would i do this? i tried
getaddrinfo() and then passing the ai_addr field of the resulting
addrinfo struct to the connect() function, but the connect fails.
a heavily shortened codesample:
doConnect(hostname) {
struct addrinfo hints, *res;
memset(&hints, 0, sizeof(hints));
hints.ai_flags = AI_CANONNAME; //AI_PASSIVE (not for clients)
hints.ai_family = PF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
getaddrinfo(in_hostname, NULL, &hints, &res);
[...]
me again...
i must specify the portname, like
getaddrinfo(in_hostname, "80", &hints, &res);
then it works better :-)
but does someone know, why trying to connect to "www.kame.net" gives a
"No route to host" error? they use ipv6, could that be a reason?
Your code is not trying to connect to 'www.kame.net'. It is (or should
be) trying to connect to a real IPv{4,6} address. What address is it
using as a destination?
The reason for getting a "no route to host" depends on your network
configuration, so again, it's hard to tell you what is going wrong
without knowing more. The error usually means that your local system
can't determine how to get a packet to the destination.
If you are using an IPv6 address as a destination, you will need more
infrastructure than is set up by default. In particular, you will need
a next-hop router address, which you only get if you set one by hand or
are in an IPv6 environment with IPv6 routers.
Regards,
Justin
--
Justin C. Walker, Curmudgeon-At-Large *
Institute for General Semantics | When LuteFisk is outlawed
| Only outlaws will have
| LuteFisk
*--------------------------------------*-------------------------------*
_______________________________________________
macnetworkprog mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/macnetworkprog
Do not post admin requests to the list. They will be ignored.