Re: Ping host and port
Re: Ping host and port
- Subject: Re: Ping host and port
- From: Tom Jones <email@hidden>
- Date: Sun, 7 Nov 2010 14:24:37 -0800
Ops, thanks!
I have not really done much with sockets. Is there an example you know of that I can learn from?
Thanks,
tom
On Nov 7, 2010, at 2:14 PM, Dave Carrigan wrote:
> On Nov 7, 2010, at 2:02 PM, Tom Jones wrote:
>> Thanks, yes its a tcp port. I tried this but for some reason "port" is always nil.
>>
>> NSSocketPort *port = [[NSSocketPort alloc] initRemoteWithTCPPort:3651 host:@"localhost"];
>> if(!port) {
>> NSLog(@"Port is open...");
>> } else {
>> NSLog(@"Port is not open...");
>> }
>> [port release];
>
> As Scott pointed out, your check is backwards. In addition, the discussion of that initializer says that the connection is not opened until data is sent, so it doesn't really matter what it returns - it still tells you nothing about if the host is actually listening on that port. For that, you would actually need to send some data and look at the result. You are way better off dropping down to socket/connect.
>
> --
> Dave Carrigan
> email@hidden
> Seattle, WA, USA
>
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden