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];

Thanks,
tom

On Nov 7, 2010, at 1:44 PM, Dave Carrigan wrote:

> On Nov 7, 2010, at 1:35 PM, Tom Jones wrote:
> 
>> I'm looking for a simple way to ping a host and a specific port on that 
>> host. I have SCNetworkCheckReachabilityByName working just fine but I really 
>> need to test to see if the port is active.
> 
> 
> ICMP (ping) doesn't use ports. I assume you actually want to determine if a 
> host is listening on a TCP or UDP port. Actually, there is no real way to 
> know if a host is listening on a UDP port unless you also know what 
> particular kind of service is associated with that port and know what to look 
> for when a host receives UDP packets on the port in question. So most likely 
> you mean a TCP port. For that, a combination of socket(2) and connect(2) 
> should tell you what you need to know. 
> 
> -- 
> Dave Carrigan
> d...@rudedog.org
> Seattle, WA, USA
> 

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to