Make the actual InetAddress instance available.

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@2085 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2002-12-22 19:13:38 +00:00
parent f13bfa62aa
commit f7786e0737
2 changed files with 8 additions and 9 deletions
@@ -1,5 +1,5 @@
//
// $Id: Connection.java,v 1.14 2002/12/22 06:36:30 mdb Exp $
// $Id: Connection.java,v 1.15 2002/12/22 19:13:38 mdb Exp $
package com.threerings.presents.server.net;
@@ -8,6 +8,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.InetAddress;
import java.net.Socket;
import java.net.SocketTimeoutException;
import java.nio.channels.SelectionKey;
@@ -83,14 +84,12 @@ public abstract class Connection implements NetEventHandler
}
/**
* Returns a string containing the IP address of the client on the
* other end of this connection or <code>&lt;disconnected&gt;</code>
* if this connection has no underlying socket channel.
* Returns the address associated with this connection or null if it
* has no underlying socket channel.
*/
public String getIPAddress ()
public InetAddress getInetAddress ()
{
return (_channel == null) ? "<disconnected>" :
String.valueOf(_channel.socket().getInetAddress());
return (_channel == null) ? null : _channel.socket().getInetAddress();
}
/**
@@ -1,5 +1,5 @@
//
// $Id: RunningConnection.java,v 1.10 2002/12/22 06:36:30 mdb Exp $
// $Id: RunningConnection.java,v 1.11 2002/12/22 19:13:38 mdb Exp $
package com.threerings.presents.server.net;
@@ -38,6 +38,6 @@ public class RunningConnection extends Connection
public String toString ()
{
return "[mode=RUNNING, id=" + (hashCode() % 1000) +
", addr=" + getIPAddress() + "]";
", addr=" + getInetAddress() + "]";
}
}