I have not found anything yet on how to check if a port is open or not. I tried to realize it with the AsyncSocket class but it returns always TRUE although I reject all connections to that port on my server.
Additionally, I tried to use the isConnected
method of AsyncSocket but that always returns FALSE.
My code so far:
//Init socket
socket=[[AsyncSocket alloc] initWithDelegate:self];
//results on TRUE always!
NSLog(@"Ready");
NSError *err = nil;
if(![socket connectToHost:@"10.1.2.40" onPort:25 error:&err])
{
NSLog(@"Error: %@", err);
}
else
{
NSLog(@"Connected");
}
//addition - results in FALSE always!
if([socket isConnected])
{
NSLog(@"yes, its connected");
}
else
{
NSLog(@"not connected...");
}
[socket disconnect];