1

I have been working on socket programming, i create a port for example :8080 and i try to send data by device's ip address with socket from one device to another but the problem is when devices get disconnected from access point (my wifi modem) they change their ip addresses on reconnecting and as i saved the old ip address socket doesn't work and i can't send any data.

is there any way to disable this ip changing and give one ip to one device all the time when it gets connected to the same access point ?

am i doing it completely wrong and shouldn't save the ip address ?

amir kam
  • 15
  • 5
  • 1
    So you want a static ip? This has already been asked multiple times for varying versions of Android - here is one for API21+ : https://stackoverflow.com/a/45385404/4252352 – Mark Mar 04 '18 at 11:09

1 Answers1

0

Method 1: You can reserve DHCP leases on the router by MAC Address.

Depending on your router model, go to the owner's website and check the manual for "Reservations"

Method 2: Assign a static IP on your Network Interface Card. Take a look on the following link here.

MiDOZ
  • 1
  • 1