-1

I am trying to routinely check whether my iPhone is on my local network. When the phone goes to sleep it quits responding to simple pings. I have read that it will wake up when sent a TCP-packet. Is there a way in Linux to send a TCP packet to an iPhone simply to wake it up long enough to respond to a regular ping?

Sean Allen
  • 31
  • 3
  • Possible duplicate of [How to write a simple Ping method in Cocoa/Objective-C](https://stackoverflow.com/q/798454/608639), [How to ping using C sockets](https://stackoverflow.com/q/14307203/608639), [Sending ICMP packets in a C program](https://stackoverflow.com/q/9688899/608639), etc. – jww Jul 28 '18 at 01:31

1 Answers1

0

For sending a TCP packet you will need a port, for example, you could use netcat:

$ echo 1  | nc <iphone ip> 80

You will need to find now out what ports are open in your iPhone and give a try to one of those ports.

Keep in mind that ping has no concept of ports (ICMP layer 3), that's why you can use it without defining a port.

nbari
  • 25,603
  • 10
  • 76
  • 131
  • When I run the line with the IP it sometimes takes a long time to finish executing. Do you know why this is? I am also not seeing a correlation between sending this packet and seeing my phone on the network. Is there a way to determine whether the TCP packet was successfully received by my phone? – Sean Allen Jul 29 '18 at 15:42
  • @SeanAllen probably is timing out since the port may not be open – nbari Jul 30 '18 at 04:32