Kanval Kalra
Kanval Kalra

Reputation: 67

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

I want to

  1. Recieve UDP message on device when it is connected through wi-fi
  2. 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

  1. UDP messeges are being recieved on device when it is connected through 2g/3g data service

  2. 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.

Upvotes: 1

Views: 1256

Answers (1)

pmoleri
pmoleri

Reputation: 4451

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.

Upvotes: 2

Related Questions