git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@1613 7e9141cc-0065-0410-87d8-b60c137991c4
This commit is contained in:
Greg Wilkins 2010-04-27 19:24:58 +00:00
parent 9c8160db02
commit 9f62516c58
3 changed files with 6 additions and 3 deletions

View File

@ -212,8 +212,8 @@ public interface Connector extends LifeCycle
/* ------------------------------------------------------------ */
/**
* @return The actual port the connector is listening on or -1 if there
* is no port or the connector is not open.
* @return The actual port the connector is listening on or
* -1 if it has not been opened, or -2 if it has been closed.
*/
int getLocalPort();

View File

@ -75,6 +75,9 @@ public class SocketConnector extends AbstractConnector
_serverSocket= newServerSocket(getHost(),getPort(),getAcceptQueueSize());
_serverSocket.setReuseAddress(getReuseAddress());
_localPort=_serverSocket.getLocalPort();
if (_localPort<=0)
throw new IllegalStateException("port not allocated for "+this);
}
/* ------------------------------------------------------------ */

View File

@ -210,7 +210,7 @@ public class SelectChannelConnector extends AbstractNIOConnector
_acceptChannel.socket().bind(addr,getAcceptQueueSize());
_localPort=_acceptChannel.socket().getLocalPort();
if (_localPort==-1)
if (_localPort<=0)
throw new IOException("Server channel not bound");
// Set to non blocking mode