Return-Path: X-Original-To: apmail-tomcat-dev-archive@www.apache.org Delivered-To: apmail-tomcat-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 242DBD2F4 for ; Sat, 25 May 2013 16:24:02 +0000 (UTC) Received: (qmail 18129 invoked by uid 500); 25 May 2013 16:24:01 -0000 Delivered-To: apmail-tomcat-dev-archive@tomcat.apache.org Received: (qmail 17837 invoked by uid 500); 25 May 2013 16:24:01 -0000 Mailing-List: contact dev-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Developers List" Delivered-To: mailing list dev@tomcat.apache.org Received: (qmail 17806 invoked by uid 99); 25 May 2013 16:24:00 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 25 May 2013 16:24:00 +0000 X-ASF-Spam-Status: No, hits=0.2 required=5.0 tests=FREEMAIL_ENVFROM_END_DIGIT,RCVD_IN_DNSWL_NONE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of elgs1980@hotmail.com designates 65.55.116.46 as permitted sender) Received: from [65.55.116.46] (HELO blu0-omc1-s35.blu0.hotmail.com) (65.55.116.46) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 25 May 2013 16:23:53 +0000 Received: from BLU0-SMTP199 ([65.55.116.7]) by blu0-omc1-s35.blu0.hotmail.com with Microsoft SMTPSVC(6.0.3790.4675); Sat, 25 May 2013 09:23:32 -0700 X-EIP: [mfPzDJnwLUHqG7T9pxSfl/ST5b3s67PG] X-Originating-Email: [elgs1980@hotmail.com] Message-ID: Received: from [192.168.0.103] ([180.158.255.1]) by BLU0-SMTP199.phx.gbl over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Sat, 25 May 2013 09:23:29 -0700 Content-Type: text/plain; charset="iso-8859-1" MIME-Version: 1.0 (Mac OS X Mail 6.3 \(1503\)) Subject: java-server-socket-binding-multiple-domain-host-names From: Elgs Chen In-Reply-To: <5182A4A4.1090407@apache.org> Date: Sun, 26 May 2013 00:23:19 +0800 CC: Tomcat Developers List Content-Transfer-Encoding: quoted-printable References: <7030EE1367513401-support@support.perfectgonzo.com> <518299E9.8000106@ptc.com> <99C8B2929B39C24493377AC7A121E21FC4ACD59717@USEA-EXCH8.na.uis.unisys.com> <5182A4A4.1090407@apache.org> To: Mark Thomas X-Mailer: Apple Mail (2.1503) X-OriginalArrivalTime: 25 May 2013 16:23:29.0805 (UTC) FILETIME=[313DABD0:01CE5964] X-Virus-Checked: Checked by ClamAV on apache.org 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: = http://stackoverflow.com/questions/16751062/java-server-socket-binding-mul= tiple-domain-host-names 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. 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 =3D (ServerSocketChannel) = selKey.channel(); String boundHost =3D sChannel.socket().getLocalAddress().getHostName(); But it does not work, the boundHost is always the server1 even if = clients connect to server2 or server3. Thanks, Elgs= --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org For additional commands, e-mail: dev-help@tomcat.apache.org