Re: Telnet Networking Example
Re: Telnet Networking Example
- Subject: Re: Telnet Networking Example
- From: Jens Alfke <email@hidden>
- Date: Thu, 23 Jul 2009 15:29:44 -0700
On Jul 23, 2009, at 3:20 PM, DerNalia wrote:
server_host = @"127.0.0.1";
NSURL *website = [NSURL URLWithString:server_host];
FYI, this was your problem. "127.0.0.1", interpreted as a URL, is just
a relative reference to some resource called "127.0.0.1". NSURL isn't
going to treat it as a hostname.
If you really wanted to create a URL out of this, you'd need a scheme
prefix, like "telnet:127.0.0.1".
NSHost *host = [NSHost hostWithName:[website host]];
Converting a host name into a URL and then extracting the host out of
it is pretty roundabout. You can just use
NSHost *host = [NSHost hostWithName: server_host];
The -hostWithAddress: call you've got now will work with numeric
addresses like the above, but if you put in something like
"foobar.com" it'll fail. -hostWithName: should handle both cases.
—Jens
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden