[multiple changes]
1999-05-26 Bryce McKinlay <bryce@albatross.co.nz> * java/net/DatagramSocket.java (getSoTimeout): Verify class type. * java/net/DatagramSocketImpl.java (getOption): Made abstract. (setOption): Made abstract. * java/net/PlainDatagramSocketImpl.java: Mirror SocketOptions fields to avoid cpp conflicts in native code. * java/net/PlainSocketImpl.java: Mirror SocketOptions fields to avoid cpp conflicts in native code. * java/net/ServerSocket.java (toString): Prepended "ServerSocket". * java/net/Socket.java (getLocalAddress): Implemented. (setTcpNoDelay): Implemented. (getTcpNoDelay): Implemented. (setSoLinger): Implemented. (getSoLinger): Implemented. (getSoTimeout): Verify class type. (setSendBufferSize): Implemented. (getSendBufferSize): Implemented. (setReceiveBufferSize): Implemented. (getReceiveBufferSize): Implemented. (toString): Prepended "Socket". * java/net/SocketImpl.java (toString): Rewritten. (getOption): Made abstract. (setOption): Made abstract. * java/net/natPlainSocketImpl.cc (connect): Set localport properly. (setOption): Implemented. (getOption): Implemented. 1999-05-26 Warren Levy <warrenl@cygnus.com> * java/net/DatagramSocket.java (DatagramSocket): Get local host address when null. Set SO_REUSEADDR for multicasts. (getSoTimeout): Implemented. (setSoTimeout): Implemented. * java/net/DatagramSocketImpl.java: Implement SocketOptions interface. * java/net/MulticastSocket.java (getInterface): Implemented. (setInterface): Implemented. (setTimeToLive): Check for invalid ttl. (joinGroup): Verify multicast address and security. (leaveGroup): Verify multicast address and security. (send): Implemented. * java/net/PlainDatagramSocketImpl.java (timeout): Added. (iface): Added. (ttl): Added. (setOption): Added. (getOption): Added. (mcastGrp): Added. (getTTL): Implemented as non-native. (setTTL): ditto. (join): ditto. (leave): ditto. * java/net/ServerSocket.java (setSoTimeout): Implemented. (getSoTimeout): Implemented. (setSocketFactory): Made synchronized. * java/net/Socket.java (setSoTimeout): Implemented. (getSoTimeout): Implemented. (close): Made synchronized. (setSocketImplFactory): Made synchronized. * java/net/SocketImpl.java: Implement SocketOptions interface. * java/net/natInetAddress.cc: Corrected module name at top of file. * java/net/natPlainDatagramSocketImpl.cc (McastReq): Added union. (bind): Added FIXME. (peek): Implemented. (setTTL): Removed. (getTTL): Removed. (join): Removed. (leave): Removed. (mcastGrp): Added. (setOption): Implemented for SO_REUSEADDR. (getOption): Implemented for SO_REUSEADDR. From-SVN: r27184
This commit is contained in:
parent
de4abb91d1
commit
f2ed9e9656
13 changed files with 608 additions and 88 deletions
|
@ -25,7 +25,8 @@ import java.io.IOException;
|
|||
public class MulticastSocket extends DatagramSocket
|
||||
{
|
||||
// FIXME: the local addr bound to the multicast socket can be reused;
|
||||
// unlike unicast sockets. see p.1159 JCL book.
|
||||
// unlike unicast sockets. It binds to any available network interface.
|
||||
// See p.1159 JCL book.
|
||||
|
||||
public MulticastSocket() throws IOException
|
||||
{
|
||||
|
@ -39,13 +40,16 @@ public class MulticastSocket extends DatagramSocket
|
|||
|
||||
public InetAddress getInterface() throws SocketException
|
||||
{
|
||||
// FIXME: TODO - MulticastSocket.getInterface
|
||||
throw new SocketException("MulticastSocket.getInterface - not yet implemented");
|
||||
// FIXME: Is it possible that an InetAddress wasn't returned from getOption?
|
||||
return (InetAddress) impl.getOption(SocketOptions.IP_MULTICAST_IF);
|
||||
}
|
||||
|
||||
// Deprecated in JDK1.2
|
||||
public byte getTTL() throws IOException
|
||||
{
|
||||
// Use getTTL here rather than getTimeToLive in case we're using an impl
|
||||
// other than the default PlainDatagramSocketImpl and it doesn't have
|
||||
// getTimeToLive yet.
|
||||
return impl.getTTL();
|
||||
}
|
||||
|
||||
|
@ -57,35 +61,66 @@ public class MulticastSocket extends DatagramSocket
|
|||
|
||||
public void setInterface(InetAddress inf) throws SocketException
|
||||
{
|
||||
// FIXME: TODO - MulticastSocket.setInterface
|
||||
throw new SocketException("MulticastSocket.setInterface - not yet implemented");
|
||||
impl.setOption(SocketOptions.IP_MULTICAST_IF, inf);
|
||||
}
|
||||
|
||||
// Deprecated in JDK1.2
|
||||
public void setTTL(byte ttl) throws IOException
|
||||
{
|
||||
// Use setTTL here rather than setTimeToLive in case we're using an impl
|
||||
// other than the default PlainDatagramSocketImpl and it doesn't have
|
||||
// setTimeToLive yet.
|
||||
impl.setTTL(ttl);
|
||||
}
|
||||
|
||||
// JDK1.2
|
||||
public void setTimeToLive(int ttl) throws IOException
|
||||
{
|
||||
if (ttl < 0 || ttl > 255)
|
||||
throw new IllegalArgumentException("Invalid ttl: " + ttl);
|
||||
|
||||
impl.setTimeToLive(ttl);
|
||||
}
|
||||
|
||||
public void joinGroup(InetAddress mcastaddr) throws IOException
|
||||
{
|
||||
if (! mcastaddr.isMulticastAddress())
|
||||
throw new IOException("Not a Multicast address");
|
||||
|
||||
SecurityManager s = System.getSecurityManager();
|
||||
if (s != null)
|
||||
s.checkMulticast(mcastaddr);
|
||||
|
||||
impl.join(mcastaddr);
|
||||
}
|
||||
|
||||
public void leaveGroup(InetAddress mcastaddr) throws IOException
|
||||
{
|
||||
if (! mcastaddr.isMulticastAddress())
|
||||
throw new IOException("Not a Multicast address");
|
||||
|
||||
SecurityManager s = System.getSecurityManager();
|
||||
if (s != null)
|
||||
s.checkMulticast(mcastaddr);
|
||||
|
||||
impl.leave(mcastaddr);
|
||||
}
|
||||
|
||||
public void send(DatagramPacket p, byte ttl) throws IOException
|
||||
public synchronized void send(DatagramPacket p, byte ttl) throws IOException
|
||||
{
|
||||
// FIXME: use ttl instead of getTTL() for time to live.
|
||||
SecurityManager s = System.getSecurityManager();
|
||||
if (s != null)
|
||||
{
|
||||
InetAddress addr = p.getAddress();
|
||||
if (addr.isMulticastAddress())
|
||||
s.checkMulticast(addr, ttl);
|
||||
else
|
||||
s.checkConnect(addr.getHostAddress(), p.getPort());
|
||||
}
|
||||
|
||||
int oldttl = impl.getTimeToLive();
|
||||
impl.setTimeToLive(((int) ttl) & 0xFF);
|
||||
impl.send(p);
|
||||
impl.setTimeToLive(oldttl);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue