Android Phone Development - UDP Services

I'm interested in the viability of implementing an Android application that interacts with a UDP service. I am sure Android supports UDP:

http://www.helloandroid.com/tutorials/simple-udp-communication-example

What is less clear to me is whether such an application will really work on an Android phone at a typical rate - for bidirectional communication. I want the Android client to contact the remotely hosted UDP service (announced by itself), and also so that the server subsequently notifies the Android device about real-time events.

I am worried that a mobile device on a commercial network may be forced to change its IP address - for example, when moving to / from a Wi-Fi zone ... and it is not clear if NAT will be a problem in a typical 3G network.

Is it possible to use UDP for bidirectional (best) communication both from an Android phone and from it?

+4
source share
1 answer

There are a few questions you can see here. Firstly, UDP is great for Android. It can send and receive UDP packets just fine. The big problem is that the phone cannot receive incoming UDP connections so that it does not open the initial connection, unless it is connected to WiFi and the connection is from the same local network.

In 3G / 4G, the phone is not addressed externally because the wireless operator has a firewall with a proxy server. Therefore, inbound connections are not transmitted through this firewall. If instead the phone opens a connection due to the firewall, then bidirectional traffic can flow through this link.

Now you will have a problem

1) Saving a link on the network when the phone goes from the network (3G) to the network (Wifi)

2) Battery life from a constantly open connection

Most likely, you really want C2DM for what you are watching.

+5
source

Source: https://habr.com/ru/post/1384923/


All Articles