• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: [newbie] specify address in various formats?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [newbie] specify address in various formats?


  • Subject: Re: [newbie] specify address in various formats?
  • From: email@hidden (Sebastian Mecklenburg)
  • Date: Sat, 24 May 2003 21:19:18 +0200

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?

regards,
sebastian mecklenburg
_______________________________________________
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.

  • Follow-Ups:
    • Re: [newbie] specify address in various formats?
      • From: "Justin C. Walker" <email@hidden>
References: 
 >[newbie] specify address in various formats? (From: email@hidden (Sebastian Mecklenburg))

  • Prev by Date: Re: [newbie] specify address in various formats?
  • Next by Date: Re: [newbie] specify address in various formats?
  • Previous by thread: Re: [newbie] specify address in various formats?
  • Next by thread: Re: [newbie] specify address in various formats?
  • Index(es):
    • Date
    • Thread