86 |
/** |
/** |
87 |
* This is the address we are "connected" to |
* This is the address we are "connected" to |
88 |
*/ |
*/ |
89 |
private InetAddress remote_addr; |
private InetAddress remoteAddress; |
90 |
|
|
91 |
/** |
/** |
92 |
* This is the port we are "connected" to |
* This is the port we are "connected" to |
93 |
*/ |
*/ |
94 |
private int remote_port = -1; |
private int remotePort = -1; |
95 |
|
|
96 |
/** |
/** |
97 |
* Is this a "connected" datagram socket? |
* Is this a "connected" datagram socket? |
98 |
*/ |
*/ |
99 |
private boolean connected = false; |
private boolean connected = false; |
100 |
|
|
|
// Constructors |
|
|
|
|
101 |
/** |
/** |
102 |
* Initializes a new instance of <code>DatagramSocket</code> that binds to |
* Initializes a new instance of <code>DatagramSocket</code> that binds to |
103 |
* a random port and every address on the local machine. |
* a random port and every address on the local machine. |
193 |
*/ |
*/ |
194 |
public InetAddress getInetAddress() |
public InetAddress getInetAddress() |
195 |
{ |
{ |
196 |
return remote_addr; |
return remoteAddress; |
197 |
} |
} |
198 |
|
|
199 |
/** |
/** |
207 |
*/ |
*/ |
208 |
public int getPort() |
public int getPort() |
209 |
{ |
{ |
210 |
return remote_port; |
return remotePort; |
211 |
} |
} |
212 |
|
|
213 |
/** |
/** |
218 |
public InetAddress getLocalAddress() |
public InetAddress getLocalAddress() |
219 |
{ |
{ |
220 |
if (impl == null) |
if (impl == null) |
221 |
return(null); |
return null; |
222 |
|
|
223 |
// FIXME: According to libgcj, checkConnect() is supposed to be called |
// FIXME: According to libgcj, checkConnect() is supposed to be called |
224 |
// before performing this operation. Problems: 1) We don't have the |
// before performing this operation. Problems: 1) We don't have the |
254 |
*/ |
*/ |
255 |
public synchronized int getSoTimeout() throws SocketException |
public synchronized int getSoTimeout() throws SocketException |
256 |
{ |
{ |
257 |
|
if (impl == null) |
258 |
|
throw new SocketException ("Cannot initialize Socket implementation"); |
259 |
|
|
260 |
Object timeout = impl.getOption(SocketOptions.SO_TIMEOUT); |
Object timeout = impl.getOption(SocketOptions.SO_TIMEOUT); |
261 |
|
|
262 |
if (timeout instanceof Integer) |
if (timeout instanceof Integer) |
297 |
*/ |
*/ |
298 |
public int getSendBufferSize() throws SocketException |
public int getSendBufferSize() throws SocketException |
299 |
{ |
{ |
300 |
|
if (impl == null) |
301 |
|
throw new SocketException ("Cannot initialize Socket implementation"); |
302 |
|
|
303 |
Object obj = impl.getOption(SocketOptions.SO_SNDBUF); |
Object obj = impl.getOption(SocketOptions.SO_SNDBUF); |
304 |
|
|
305 |
if (obj instanceof Integer) |
if (obj instanceof Integer) |
341 |
*/ |
*/ |
342 |
public int getReceiveBufferSize() throws SocketException |
public int getReceiveBufferSize() throws SocketException |
343 |
{ |
{ |
344 |
|
if (impl == null) |
345 |
|
throw new SocketException ("Cannot initialize Socket implementation"); |
346 |
|
|
347 |
Object obj = impl.getOption(SocketOptions.SO_RCVBUF); |
Object obj = impl.getOption(SocketOptions.SO_RCVBUF); |
348 |
|
|
349 |
if (obj instanceof Integer) |
if (obj instanceof Integer) |
400 |
if (sm != null) |
if (sm != null) |
401 |
sm.checkConnect(addr.getHostName(), port); |
sm.checkConnect(addr.getHostName(), port); |
402 |
|
|
403 |
this.remote_addr = addr; |
this.remoteAddress = addr; |
404 |
this.remote_port = port; |
this.remotePort = port; |
405 |
|
|
406 |
/* FIXME: Shit, we can't do this even though the OS supports it since this |
/* FIXME: Shit, we can't do this even though the OS supports it since this |
407 |
method isn't in DatagramSocketImpl. */ |
method isn't in DatagramSocketImpl. */ |
420 |
public void disconnect() |
public void disconnect() |
421 |
{ |
{ |
422 |
// FIXME: See my comments on connect() |
// FIXME: See my comments on connect() |
423 |
this.remote_addr = null; |
this.remoteAddress = null; |
424 |
this.remote_port = -1; |
this.remotePort = -1; |
425 |
connected = false; |
connected = false; |
426 |
} |
} |
427 |
|
|
442 |
s.checkAccept(p.getAddress().getHostAddress(), p.getPort()); |
s.checkAccept(p.getAddress().getHostAddress(), p.getPort()); |
443 |
|
|
444 |
impl.receive(p); |
impl.receive(p); |
445 |
|
|
446 |
|
SecurityManager s = System.getSecurityManager(); |
447 |
|
if (s != null && isConnected ()) |
448 |
|
s.checkAccept (p.getAddress().getHostName (), p.getPort ()); |
449 |
} |
} |
450 |
|
|
451 |
/** |
/** |
565 |
*/ |
*/ |
566 |
public boolean isConnected() |
public boolean isConnected() |
567 |
{ |
{ |
568 |
return remote_addr != null; |
return remoteAddress != null; |
569 |
} |
} |
570 |
|
|
571 |
/** |
/** |
579 |
if (!isConnected ()) |
if (!isConnected ()) |
580 |
return null; |
return null; |
581 |
|
|
582 |
return new InetSocketAddress (remote_addr, remote_port); |
return new InetSocketAddress (remoteAddress, remotePort); |
583 |
} |
} |
584 |
|
|
585 |
/** |
/** |