title: How to ping an ipaddress at a specific port ios app
body: <p>Im trying to ping all ip addresses at my network. I'm able to get my ip now im trying to ping all of other ip's in my network. i have this ip xxx.xxx.xxx.121 , il have to ping xxx.xxx.xxx.1 to xxx.xxx.xxx.255.Im using simpleping by the way. </p>
  
  <pre><code>for (int i = 0; i&lt;256; i++) {
          NSString *str = [NSString stringWithFormat:@"%@.%i",searchingIp,i];
          NSLog(@"ipStr:%@",str);
  
          const char *address = [str UTF8String];
          NSLog(@"%s",address);
  
          struct sockaddr_in callAddress;
          callAddress.sin_len = sizeof(callAddress);
          callAddress.sin_family = AF_INET;
          callAddress.sin_port = htons(49160);
          callAddress.sin_addr.s_addr = inet_addr(address);
  
          NSLog(@"%s:%d",inet_ntoa(((struct sockaddr_in*)&amp;callAddress)-&gt;sin_addr),((struct sockaddr_in*)&amp;callAddress)-&gt;sin_port);
  
  
          simplePing = [SimplePing simplePingWithHostAddress:[NSData dataWithBytes:&amp;callAddress length:sizeof(callAddress)]];
          simplePing.delegate = self;
          [simplePing start];
      }
  </code></pre>
  
  <p>I also tried to set the port with "49160" but still it shows 2240.
  Im kinda new in this type of stuff.</p>