tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Elgs Chen <>
Subject java-server-socket-binding-multiple-domain-host-names
Date Sat, 25 May 2013 16:23:19 GMT
Hi Mark,

I'm very sorry I know this is not related to the Tomcat project. However, I cannot find anyone
who I think has more expertise in java networking programming than you.

I have a java server socket problem and I have no way to find the answer. I'm really hoping
I can get some insights from you. Thanks in advance.

And here's the URL to this question:

I have a java nio server with ip address 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

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.

Now the question is: seems on the server side, I cannot easily get the correct information
which server name my clients are connecting to.

I have the follow code:

ServerSocketChannel ssChannel = (ServerSocketChannel);
String boundHost = sChannel.socket().getLocalAddress().getHostName();
But it does not work, the boundHost is always the server1 even if clients connect to server2
or server3.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message