for a server, i want to determine whether two clients is in the same LAN.
the clients may show me there local ips. such as 192.168.x.x . they are both LAN ip. they don't have public ip.
is there any identifier for a LAN?
for a server, i want to determine whether two clients is in the same LAN.
the clients may show me there local ips. such as 192.168.x.x . they are both LAN ip. they don't have public ip.
is there any identifier for a LAN?
You need the network mask to determine if IP addresses are in the same network.
The way to determine if two addresses are in the same network is to mask (logical AND
) the addresses with a network mask. For example:
Address 10.11.12.13 -> 00001010000010110000110000001101
Mask 255.255.192.0 -> 11111111111111111100000000000000
AND ================================
Network -> 00001010000010110000000000000000 -> 10.11.0.0