Reputation: 1181
I have a Windows-based application which can do some sort of work.
I want to make an iOS application that can send message over Internet to particular application running on destination computer.
So, my question is how to tie my iOS client and Windows server applications without specifying IP address and port, just using some sort of key like that works in Team Viewer, for example: server application has a key and password set and client application from another network can connect to server application with matching key and correct password.
I don't need to share screen or something, just want to send/get binary messages.
Is there a way to connect applications without using some kinds of web services?
Or using web service just to establish connection for client and server applications and not to control message queue?
Upvotes: 2
Views: 1206
Reputation: 7295
I believe what you need is a peer to peer communication channel between the server Application and the iOS one, the major problem here is you need to Traverse NATs between these two devices.
There are several methods to achieve this, UDP Hole Punching is one of them, which is easy to implement and has high success rate in NAT traversal.
To establish the connection with this method, you essentially need three components:
Peer: A Traditional UDP Client/Server, it's the same as your UDP application which works on LAN.
STUN Server: A Server for Simple Traversal of User Data-gram Protocol (UDP) through Network Address Translators (NATs). it just helps you to map your local computer address to public one.
You don't need to Write or deploy your own, there are several STUN servers ready for public use, 203.183.172.196:3478 (s1.taraba.net)
is one of them (there are also some Open source implementations if you need to deploy your own e.g. http://sourceforge.net/projects/stun/).
A compiled list of public STUN Servers: https://gist.github.com/zziuni/3741933
Here is a simple implementation of STUN Client with a good explanation: http://www.codeproject.com/Articles/18492/STUN-Client
Rendezvous Server: A simple public server which holds public addresses for all online peers.
Communication Steps:
Announcement
1- The Peer query itself from STUN Server to find it's Public IP:Port address.
2- The Peer announces itself to Rendezvous Server, and sets it's status for communication.
3- A Peer should update its state and public address periodically.
Connection
1- Application will find public Address of target Peer from Rendezvous Server (based on ID/Token, ...)
2- Application will establish a UDP connection with provided public IP:Port address the same as Traditional LAN UDP communication.
3- Application should check Rendezvous Server to update target peer Public address/Status.
NOTE: UDP Hole punching will not work with all NAT combinations, in such situations you should use a Relay Server to establish a connection, it essentially works as a link between pears that cannot see each other (their NATs are blocked)
I suggest you to have a look at http://www.brynosaurus.com/pub/net/p2pnat/ for more information about peer to peer communication through NATs.
Upvotes: 10