[code]public int getPort() {
if (!isConnected())
return 0;
try {
return getImpl().getPort();
} catch (SocketException e) {
// Shouldn't happen as we're connected
}
return -1;
}
SocketImpl getImpl() throws SocketException {
if (!created)
createImpl(true);
return impl;
}
void setImpl() {
if (factory != null) {
impl = factory.createSocketImpl();
checkOldImpl();
} else {
// No need to do a checkOldImpl() here, we know it's an up to date
// SocketImpl!
impl = new SocksSocketImpl();
}
if (impl != null)
impl.setSocket(this);
}[/code]自己看源码吧,帮你摘出来一些!! |