imkira / mobiledevice

Command line utility for interacting with Apple's Private (Closed) Mobile Device Framework
MIT License
674 stars 140 forks source link

How to send data from Mac to iPhone using mobiledevice #12

Open sauvikatinnofied opened 7 years ago

sauvikatinnofied commented 7 years ago

I was trying to send some data from Mac to iPhone. On Mac, I run the command mobiledevice tunnel 8000 80
assuming all the incoming call to Mac (localhost:8000) will be forwarded to iPhone, any app running on iPhone and listening on localhost:80 can get the data. On iPhone I used Socket.IO-Client-Swift

I tried to open localhost:8000 on Safari and get the following output on console

Tunneling from local port 8000 to device port 80...
Got new client!
Device refused connection to port 80!
Got new client!
Device refused connection to port 80!
Got new client!
Device refused connection to port 80!

I never get a call back on my iPhone app. Can anyone help me how to use this tunneling facility and receive data to iPhone app from Mac?

Please find my iPhone test app here. ClaraByteTestApp.zip

imkira commented 7 years ago

Are you sure your app can actually listen on 80? Can you try listening on a port higher than 1024?

sauvikatinnofied commented 7 years ago

Thanks @imkira, I will try that one on Monday. I will let you know icthe result. Currently enjoying my weekend. 😊

sauvikatinnofied commented 7 years ago

Thanks @imkira once again for your suggestion, I have successfully tested the connection with a higher port number 2345 using the PTChannel instance from https://github.com/rsms/peertalk library. I used telnet localhost 8000 to establish a connection on 2345 on the iOS device. I am receiving device info back to my terminal sent from iPhone.

I am still facing problem to send custom data to the channel from Mac to the iOS device. Can you please help me to find out a way to send a custom string data from Mac terminal to iPhone?