0

I opened a socket connection. I want to know server IP address

    NSString *urlString = [NSString stringWithFormat:@"http://sample.com"];

    NSURL *website = [NSURL URLWithString:urlString];
    CFReadStreamRef readStream;
    CFWriteStreamRef writeStream;
    CFStreamCreatePairWithSocketToHost(NULL, ( CFStringRef)[website host], [portNo intValue], &readStream, &writeStream);
    
    CFReadStreamSetProperty(readStream,kCFStreamNetworkServiceType,kCFStreamNetworkServiceTypeVoIP);
    CFWriteStreamSetProperty(writeStream,kCFStreamNetworkServiceType,kCFStreamNetworkServiceTypeVoIP);

    inputStream = ( NSInputStream *)readStream;
    outputStream = ( NSOutputStream *)writeStream;
    [inputStream open];
    [outputStream open];
Fattaneh Talebi
  • 727
  • 1
  • 16
  • 42

1 Answers1

0

You can do a DNS lookup and get this info. A DNS lookup can be performed on any host name. See here: How to perform DNS query on iOS

Arik Segal
  • 2,963
  • 2
  • 17
  • 29