Don't use getHostName() is all you care about is the IP address. getHostName() will attempt a reverse name lookup which not only is usually unnecessary, but can take up a lot of extra time and resources. Stick with getHostAddress() and getAddress(). getAddress() is your best bet as an integer is a lot less memory than the string.
Also, if you DO need to do reverse name lookups (or normal DNS lookups), I highly recommend avoiding Java's builtin resolver, and use something like DNSJava, which tends to be much faster and not subject to Java and OS settings causing problems. 2009/3/3 Emmanuel Lecharny <[email protected]>: > Safa wrote: >> >> Hi Everyone, >> >> I am running a multiplayer game server based on MINA, where 8k users can >> be >> online at certain times of a day. For the latest update I have been doing >> to >> my server, I needed to determine if multiple accounts log in from the same >> IP address. For this, I used IoSession.getRemoteAddress() and downcast to >> InetAddress, then store the result of getHostName() in a string. >> > > Why don't you just store the address in a 'int' ? If it's a Inet4 address, > it should be just what you need to keep an address in memory, and you > certainly can hold hundred of thousands of those guys in memory... > > The only problem is when you have more than one port used for a IP > address... > > -- > -- > cordialement, regards, > Emmanuel Lécharny > www.iktek.com > directory.apache.org > > >
