Send UDP message to Android phone from JAVA server - java

I need to implement a messaging system for Android phones.
The server has static IP, it runs JAVA and it should send periodically UDP ping messages to android phones.
As I understand mobile phones have NAT IP.
The question is how server can send message to this IP.

Related

How to find specific desktop's ip address on network?

I'm coding an app which consist of two pieces. Desktop and android. There is one desktop and several android devices. (don't know the count.) I want to communicate android devices between desktop with TCP. However, android devices doesn't know desktop's lan ip address.
I thouht 2 ways:
1-Desktop app changes the local ip address on start. So android devices know the ip address. (I coded with that ip address)
2-Desktop app always tries to connect ip addresses (192.168.0.1 - 192.168.0.255) to sent desktop's ip address. And when an android device connect to the network accept the connection then know desktop's ip.
But there is some problems in both ways.
On first, you must be administrator to changing lan ip. So run command as admin with java is a problem. Because if I do this, when user start the program, uac always asks for it.
On second, I think there will be performance issues because of app always tries to connect. Exept this, when android device connect and dhcp gives it 192.168.0.5 , but loop is on 192.168.0.150. So android device have to wait for connection.
Is there a better way than these?
Look at this post Network discovery in Java using multicasting
I think this would be the best way to do it.
The server will listen for a broadcast message from client
the client sends a broadcast request asking for server ip
server receives request and replies back with server ip.
You can use the hostname. If the network is properly configured, the host name will point to the correct ip even if it changes

Creating two sockets at client side android app

Hi I am new to socket programming.I am developing a client- server application. My server will a Java application. My client will be an android App. what i want to do is that i want to send data over both the channels i.e WiFi and 3G network. Is this Possible to send some packets over WiFi and some over 3G.
Is such a mechanism possible. If yes how can i accomplish this?
what I thought that i will create two sockets at client side and bind them to their specific IP's i.e bind one socket with wifi IP and other with 3G network IP.
Is there any provision of binding IP's with sockets at client side.

How to send a multicast over the wifi tethering network?

I'm building an app to send a multicast message from all the devices to 224.0.0.1 so that every 1 in the network can receive it. But once i set up a tethering network and let all the devices join the network and do the multicast only the hosting device does not receive the multicast and other devices does not receive tethering hosting device multicast. How can i make the tethering device also receive multicast data packets?

Java: Sending/Recieving Udp packet in Device being behind wi-fi router

I want to
Recieve UDP message on device when it is connected through wi-fi
Know how to send udp message on device when it is connected to wi-fi
router as the sender on diffrent network
What i have tried
http://code.google.com/p/boxeeremote/wiki/AndroidUDP
What is working
UDP messeges are being recieved on device when it is connected
through 2g/3g data service
UDP messeges are being recieved when sender and reciever are both in
same network ( behind wi-fi router )
Any help/point in right direction is appreciated.
When the device is behind a wi-fi router, it has a private address so it isn't reachable from outside the private network, at least no without some extra work.
You need to do Hole Punching, is what applications like Skype do to receive UDP packets. Applications usually use a STUN server in order to achieve this.
The easiest alternative would be to have a server with a public address and make all the devices connect to the server with tcp/ip protocol. If you can't afford that you need to do Hole Punching.

Android: UDP Packets not reaching CDMA Device

Referred to this link and i have done sample Client/Server Apps using android.The apps work well on GSM sim's able to send and receive packets,but on CDMA device i am not able to receive any packets but able to send packets.
Ip address details is drawn from this app
Whats going on here?

Categories

Resources