title: Java Server Socket binding multiple domain/host names
body: <p>I have a java nio server with ip address 192.168.0.1 listening on port 80. I configured this server to bind to multiple domain/host names, let's say server1, server2, server3 are all resolved as 192.168.0.1. </p>
  
  <p>Now I'm hoping if the client connects to server1, on the server side, I can recognize that the client is connecting to server1 instead of other names or direct ip address, so that I can do something special, and if the client is connecting to server2, I can recognize that the client is requesting server2, so I can do something else special, and so on.</p>
  
  <p>Now the question is: seems on the server side, I cannot easily get the correct information which server name my clients are connecting to.</p>
  
  <p>I have the follow code:</p>
  
  <pre><code>ServerSocketChannel ssChannel = (ServerSocketChannel) selKey.channel();
  String boundHost = sChannel.socket().getLocalAddress().getHostName();
  </code></pre>
  
  <p>But it does not work, the boundHost is always the server1 even if clients connect to server2 or server3.</p>