I am working on a small project to make a client server program to make a connectionless implementation & I want to transmit Information between 2 devices which is connected to the same Wi-Fi hotspot & so they are showing same IPV4 address . How can I differentiate between the 2 devices or could I possibly use IPV6 address to make client server program?
connected to the same Wi-Fi hotspot & so they are showing same IPV4 address .
Apparently, they are NATed towards your server. If this is on the same enterprise network you should remove NAT.
How can I differentiate between the 2 devices
On the network level, you can't. On the application level, you might use some kind of fingerprinting or authentication, but that is off-topic here. Possibly Stack Overflow is the right place to ask.
or could I possibly use IPV6 address to make client server program?
Possibly. The clients might be using various v6 IPs, so you can't be 100% sure.
... between 2 devices which is connected to the same Wi-Fi hotspot & so they are showing same IPV4 address.
This is not really the way NAT is working:
The Wi-Fi network (the same is true for a home network) forms a local network. All devices in the network have their own IP addresses. However, these IP addresses are not valid in the internet.
To establish a connection (for example a TCP connection) to a computer in the internet, a device actually establishes a connection to a NAT router or proxy server, which then establishes a connection to the computer in the internet.
So actually the global IP address is not shared between the devices, but the only devices really using the global IP address is the NAT router or proxy server. And actually none of the devices inside the network is really connected to the internet, but only the NAT router or proxy server is.
How can I differentiate between the 2 devices ...
If both devices are in the same Wi-Fi network, you don't have any problem:
Both devices have an own IP address.
However there are Wi-Fi networks with a firewall that does only allow devices to communicate to the NAT router but not with each other. In this case you have no chance.
If only one device is in the Wi-Fi network (and the other one is in another Wi-Fi network), you will also have no chance:
As I already wrote, the only device which is really connected to the internet is the NAT router. And by default this router won't forward UDP packets to the device.
... IPV6 ...
In most cases all devices will have an IPv6 address which is valid in the entire internet. So devices inside the Wi-Fi network can communicate directly to computers in the internet.
- Most Wi-Fi routers for IPv6 have a "stateful firewall" which will block packets which would be blocked in an IPv4 Wi-Fi network by default.
- There surely are networks that work using proxy servers or NATs ("NAT66") together with IPv6.