Question

When a Client makes a connection to your Server, is it possible to determine the hostname they used to connect to it? For example, if both entry1.domain.com and entry2.domain.com point to the same IP (your server), and a Client uses one to connect to your server are you able to differentiate between which hostname was used to make the socket connection?

Was it helpful?

Solution

Normally the client sends the host name desired to the server. E.g. this is what HTTP does. You can send data you want over TCP. i.e. you can send the desired host name.

Another approach is to use multiple IP addresses for the same host and bind to different IP addresses in Java. This way you know which address was used assuming it is unique.

OTHER TIPS

Not from a pure TCP connection. You can get the IP address, but you can't know what hostname the client used to get that IP address.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top