54 |
DatagramSocketImpl impl; |
DatagramSocketImpl impl; |
55 |
|
|
56 |
/** |
/** |
57 |
|
* This is the local address which cannot be changed |
58 |
|
*/ |
59 |
|
private InetAddress local_addr; |
60 |
|
|
61 |
|
/** |
62 |
* This is the address we are "connected" to |
* This is the address we are "connected" to |
63 |
*/ |
*/ |
64 |
private InetAddress remote_addr; |
private InetAddress remote_addr; |
138 |
if (addr == null) |
if (addr == null) |
139 |
addr = InetAddress.getInaddrAny(); |
addr = InetAddress.getInaddrAny(); |
140 |
|
|
141 |
|
local_addr = addr; |
142 |
impl.localPort = port; |
impl.localPort = port; |
143 |
impl.bind(port, addr); |
impl.bind(port, addr); |
144 |
|
|
201 |
if (impl == null) |
if (impl == null) |
202 |
return(null); |
return(null); |
203 |
|
|
|
InetAddress addr = null; |
|
|
try |
|
|
{ |
|
|
addr = (InetAddress)impl.getOption(SocketOptions.SO_BINDADDR); |
|
|
} |
|
|
catch(SocketException e) |
|
|
{ |
|
|
return(null); |
|
|
} |
|
|
|
|
204 |
// FIXME: According to libgcj, checkConnect() is supposed to be called |
// FIXME: According to libgcj, checkConnect() is supposed to be called |
205 |
// before performing this operation. Problems: 1) We don't have the |
// before performing this operation. Problems: 1) We don't have the |
206 |
// addr until after we do it, so we do a post check. 2). The docs I |
// addr until after we do it, so we do a post check. 2). The docs I |
208 |
// we'll assume they mean both. |
// we'll assume they mean both. |
209 |
SecurityManager sm = System.getSecurityManager(); |
SecurityManager sm = System.getSecurityManager(); |
210 |
if (sm != null) |
if (sm != null) |
211 |
sm.checkConnect(addr.getHostName(), getLocalPort()); |
sm.checkConnect(local_addr.getHostName(), getLocalPort()); |
212 |
|
|
213 |
return(addr); |
return(local_addr); |
214 |
} |
} |
215 |
|
|
216 |
/*************************************************************************/ |
/*************************************************************************/ |