문제

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?

도움이 되었습니까?

해결책

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.

다른 팁

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top