249 |
*/ |
*/ |
250 |
public InetAddress getLocalAddress() |
public InetAddress getLocalAddress() |
251 |
{ |
{ |
252 |
if (impl == null) |
if (impl == null |
253 |
|
|| closed) |
254 |
return null; |
return null; |
255 |
|
|
|
// FIXME: According to libgcj, checkConnect() is supposed to be called |
|
|
// before performing this operation. Problems: 1) We don't have the |
|
|
// addr until after we do it, so we do a post check. 2). The docs I |
|
|
// see don't require this in the Socket case, only DatagramSocket, but |
|
|
// we'll assume they mean both. |
|
|
|
|
256 |
InetAddress localAddr; |
InetAddress localAddr; |
257 |
|
|
258 |
try |
try |
259 |
{ |
{ |
260 |
localAddr = (InetAddress) impl.getOption (SocketOptions.SO_BINDADDR); |
localAddr = (InetAddress) impl.getOption (SocketOptions.SO_BINDADDR); |
261 |
|
|
262 |
|
SecurityManager s = System.getSecurityManager(); |
263 |
|
if (s != null) |
264 |
|
s.checkConnect (localAddr.getHostName(), -1); |
265 |
|
} |
266 |
|
catch (SecurityException e) |
267 |
|
{ |
268 |
|
localAddr = InetAddress.ANY_IF; |
269 |
} |
} |
270 |
catch (SocketException e) |
catch (SocketException e) |
271 |
{ |
{ |
272 |
return null; |
return null; |
273 |
} |
} |
|
|
|
|
SecurityManager sm = System.getSecurityManager(); |
|
|
if (sm != null) |
|
|
sm.checkConnect(localAddr.getHostName(), getLocalPort()); |
|
274 |
|
|
275 |
return localAddr; |
return localAddr; |
276 |
} |
} |