How can an iPhone communicate with a computer? - iphone

How do apps like Apple's "Remote" app control mac applications and send data?
is this via php with exec() commands or some other method? and how would I do it in c?
Also, how fast is this rate of transfer (can I use it to send real-time data like streaming video or audio?)
thanks to anyone who cares to enlighten me on this issue :-)

Apps generally communicate using a TCP/IP based protocol and the wireless LAN connection (the iPhone also has Bluetooth). In the case of the Remote app the communication is via with the Digital Audio Control Protocol. iTunes implements DACP so the Remote app can control it. Other common protocols are HTTP and FTP. There are classes in the iPhone SDK to connect to noth HTTP and FTP servers. There is also the Cocoa HTTP Server project which allows the iPhone to act as a HTTP server.
iPhone apps can also use Bonjour/mDNS/zeroconfig (they're different names for the same technology) so that the user doesn't have to be concerned with configuring IP address'.
The data transfer rate of the wireless connection is faster enough to stream video.

many of these remote applications work by installing client software on the computer and establishing a network connection. In the case of Apple's remote software, the client software is built into the networking capabilities of iTunes. You must authenticate using your iTunes sign in and be on local wifi.
The third party app "intelliremote" works very similarly only has it's own client software to install and can work across a WAN with proper port forwarding enabled on your network.
I haven't encountered any realtime streaming options as most of these utilities are designed to pass control messages and meta-info on media files.

Related

Discover devices (esp8266/arduino) on same LAN subnet

I am developing a product which uses ESP8266 (arduino firmware). I am developing an Ionic app as the main controller. The product is working perfectly fine through the server. But a major feature needed is to communicate with the devices through LAN. The devices host a server so I can communicate with them using GET requests through my app using their local IP.
But the problem is discovering these devices. Currently my approach is to send a get request on all IPs on my subnet and parse the response, if any, and store the active IPs in app; then use those stored IPs to communicate for subsequent requests.
The problem is the sending request to all IPs part. It is a slow process and slower with low end phones.
What I want is a way to receive communication from the devices initiated by them, maybe. Something like signalling all IPs (just my devices) at once to send their IPs to my phone.
Can this be done easily? And quickly? And accurately?
One option is to set up the ESP8266 to publish an mDNS service (also known as zeroconf, bonjour, etc..). Luckily, mDNS is built into the ESP8266 Arduino core. There is some basic setup info here: https://tttapa.github.io/ESP8266/Chap08%20-%20mDNS.html, as well as elsewhere on the web.
Then on the ionic side, you can then use a zeroconf/mDNS plugin to automatically discover the ESP8266. I've used this one in the past, with good results: https://ionicframework.com/docs/native/zeroconf/

Communicating with Windows from an iPhone/iPod

I'm looking to work on an iOS app that would need to send/receive data back and forth between the iPhone/iPod and a service that is running on Windows. Communication-wise, I will be using sockets.
The Phone will send/receive data to/from a Windows service (NOT a web service)
Sockets will be used as a means for communication
The iPhone/iPod will be connected to WiFi using a static IP address
The iPhone/iPod is intended to be as thin client as possible
The intention is to have the Windows Service listen for events from iPhone/iPod. Example:
Input needs to be taken from a UITextField and saved as a string by pressing a button. On the button press, an event must be fired and sent to the Windows Service over WiFi, which will then receive the event, perform a "server-side" action, and send the response back to the iPhone/iPod.
I'm pretty new to iOS development still and I know this is some more advanced stuff, but any help or resources that would help to accomplish this, I'd appreciate it.
Thanks!
This is standard network stuff not related to which platform you're using. On iOS you can do either:
1) use berkley sockets (standard unix stuff).
2) use the Cocoa wrapper for sockets (NSSocketPort etc).
3) use a framework such as MKNetworkKit (here).
I would use option 3 myself :)
One thing in your favour is that Windows machines and iPads are both little-endian, so you don't have to worry about byte-swapping (which you won't anyway if you're just sending strings).
EDIT: For windows to discover your device, you will need either a configuration setup with the IP address details, or to use Apple's bonjour service, or some custom solution.

Communication between iOS app in one Wi-Fi network w/o server

I need to communicate my app with 2 devices. A restriction is that I can't use a server but all iOS devices will be in one Wi-Fi network. What options do I have? How I can send a message to another copy of my app running on another device?
I dont know whether its a correct approach or not but as you cannot use server,so the approach i can think of is we can create a socket connection using TCP/IP or UDP(based on reliability) for data exchange.
I dont think you can communicate between 2 devices running the same application without having some kind of server application in-between.
Even if you could find the other device over the WIFI I dont think you can tell if the other device is running the app or not.
I think you may be referring to MultipeerConnectivity
The Multipeer Connectivity framework provides support for discovering
services provided by nearby iOS devices using infrastructure Wi-Fi
networks, peer-to-peer Wi-Fi, and Bluetooth personal area networks and
subsequently communicating with those services by sending
message-based data, streaming data, and resources (such as files).
Source: https://developer.apple.com/library/ios/documentation/MultipeerConnectivity/Reference/MultipeerConnectivityFramework/
Apple Sample:
https://developer.apple.com/library/ios/samplecode/MultipeerGroupChat/Introduction/Intro.html

iPhone (behind cellular NAT) peer-to-peer internet connection with a server

I have an iPhone on a 3G cellular network and a server on the internet and I want them to be able to exchange messages bidirectionally. Sometimes the iPhone makes a request to the Server some other times the Server makes a request to the iPhone. Problem is that the iPhone is behind the NAT of the cellular network and it doesn't have a fixed ip:port , on every new connection the port changes.
I think I have to make a bidirectional socket SO_REUSEADDR/SO_REUSEPORT and make the connection persistent.
The other two solutions are Apple's Push notification and long polling, for now I need an answer for the P2P solution between the iPhone and the Server.
Can you advise me on what I have to do or provide me a working example code where an iPhone can receive messages from a host that is on the internet?
It is a pity that Java is not supported on the iPhone, because the JXTA framework would have solved your issue easily.
What you are looking for is a TURN like implementation of P2P. The Iphone has to initiate the connection to the server to punch the hole in the NAT and yes, it has to be kept alive (even if you investigate more sophisticated implementations like STUNT for NAT traversal).
With TURN, the server has to transmit messages between IPhones, with STUNT, messages are transferred directly between devices, but it is quite complicated to implement properly.
i've been doing a lot of reading up on these things and my understanding is that XMPP is the solution for you. use an open source XMPP server (like openfire) and XMPPframework (an ios module).

Secure iPhone-Desktop Connection

Background
There are a lot of App Store released iPhone apps that require an IP based server on the desktop so that the iPhone can connect to the desktop as a client. For example, there are many programs that emulate a keyboard, touchpad, or Apple remote on the iPhone so that a desktop computer can be controlled over wifi. However, many of these applications get around writing their own server by requiring the user to install some VNC server variant.
Question
What is the best way to implement a secure (encrypted) IP server on a desktop (Mac and Windows platforms) that allows for simple two way message passing between itself and an iPhone client on a wifi network?
Sample Use Case
An event on the desktop causes the desktop to push a small image or text to the iPhone. An event on the iPhone causes a short text message to be pushed to the desktop. Any single event can happen at any time (doesn't appear synchronized to the user).
1st Follow-Up Question
Would this type of project be best handled using something like XML or JSON over HTTP? Or is there a better protocol, like BEEP or Bonjour(XMPP)?
What is the best way to implement a secure (encrypted) IP server on a desktop (Mac and Windows platforms) that allows for simple two way message passing between itself and an iPhone client on a wifi network?
Not sure if there is a "best" way, but much code is already available to do xyz-over-HTTPS (TLS/SSL). In that case, the "xyz" can be any web-based message exchange protocol, such as XML, JSON, etc. via REST or SOAP, etc.
If you want to be able to push events to a non-jailbroken iPhone you can't do it other than via Apple's Push Server which causes a notification to the client program if it is running or otherwise displays an alert of some kind to the user.
Typical architecture has those notifications handled by the client program as an indication it should go and get some data from the server - Apple insist we do not regard the notifications as trusted delivery.
I suggest a read of this article on using Bonjour and local networking, whilst it's iPhone to iPhone it should apply to desktop OS/X also.