• 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: Ping host and port
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Ping host and port


  • Subject: Re: Ping host and port
  • From: Dave Carrigan <email@hidden>
  • Date: Sun, 7 Nov 2010 14:14:11 -0800

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

  • Follow-Ups:
    • Re: Ping host and port
      • From: Tom Jones <email@hidden>
References: 
 >Ping host and port (From: Tom Jones <email@hidden>)
 >Re: Ping host and port (From: Tom Jones <email@hidden>)

  • Prev by Date: Re: Ping host and port
  • Next by Date: Re: Moving Properties to
  • Previous by thread: Re: Ping host and port
  • Next by thread: Re: Ping host and port
  • Index(es):
    • Date
    • Thread