Commit 4aa74bd3 by Michael Koch Committed by Michael Koch

2003-11-26 Michael Koch <konqueror@gmx.de>

	* java/net/DatagramSocket.java
	(impl): Made private.
	(bound): New private member variable.
	(DatagramSocket): Fixed documentation, use getImpl().
	(getImpl): New package-private method.
	(isClosed): Use getImpl().
	(getLocalAddress): Completed documentation, use getImpl().
	(getLocalPort): Use getImpl().
	(getSoTimeout): Likewise.
	(setSoTimeout): Likewise.
	(getSendBufferSize): Likewise.
	(setSendBufferSize): Likewise.
	(getReceiveBufferSize): Likewise.
	(setReceiveBufferSize): Likewise.
	(connect): Likewise.
	(disconnect): Likewise.
	(receive): Likewise.
	(send): Likewise.
	(setReuseAddress): Likewise.
	(setTrafficClass): Likewise.
	(bind): Added message to exception.
	(isClosed): Completed documentation.
	(getChannel): Likewise.
	(connect): Added missing exception, refined exception message.
	(isBound): Completed documentation, just return bound.
	(isConnected): Completed documentation.
	(getRemoteSocketAddress): Likewise.
	(getReuseAddress): Completed documentation, use getImpl().
	(setSoBroadcast): Likewise.
	(getSoBroadcast): Likewise.
	(getTrafficClass): Likewise.
	(getLocalSocketAddress): Simplified.
	* java/net/MulticastSocket.java
	(MulticastSocket): Removed comment not applying anymore.
	(getInterface): Use getImpl().
	(getTTL): Likewise.
	(getTimeToLive): Likewise.
	(setInterface): Likewise.
	(setNetworkInterface): Likewise.
	(getNetworkInterface): Likewise.
	(setLoopback): Likewise.
	(getLoopback): Likewise.
	(setTTL): Likewise.
	(setTimeToLive): Likewise.
	(joinGroup): Likewise.
	(leaveGroup): Likewise.
	(send): Likewise.

From-SVN: r73951
parent 88096b2a
2003-11-26 Michael Koch <konqueror@gmx.de> 2003-11-26 Michael Koch <konqueror@gmx.de>
* java/net/DatagramSocket.java
(impl): Made private.
(bound): New private member variable.
(DatagramSocket): Fixed documentation, use getImpl().
(getImpl): New package-private method.
(isClosed): Use getImpl().
(getLocalAddress): Completed documentation, use getImpl().
(getLocalPort): Use getImpl().
(getSoTimeout): Likewise.
(setSoTimeout): Likewise.
(getSendBufferSize): Likewise.
(setSendBufferSize): Likewise.
(getReceiveBufferSize): Likewise.
(setReceiveBufferSize): Likewise.
(connect): Likewise.
(disconnect): Likewise.
(receive): Likewise.
(send): Likewise.
(setReuseAddress): Likewise.
(setTrafficClass): Likewise.
(bind): Added message to exception.
(isClosed): Completed documentation.
(getChannel): Likewise.
(connect): Added missing exception, refined exception message.
(isBound): Completed documentation, just return bound.
(isConnected): Completed documentation.
(getRemoteSocketAddress): Likewise.
(getReuseAddress): Completed documentation, use getImpl().
(setSoBroadcast): Likewise.
(getSoBroadcast): Likewise.
(getTrafficClass): Likewise.
(getLocalSocketAddress): Simplified.
* java/net/MulticastSocket.java
(MulticastSocket): Removed comment not applying anymore.
(getInterface): Use getImpl().
(getTTL): Likewise.
(getTimeToLive): Likewise.
(setInterface): Likewise.
(setNetworkInterface): Likewise.
(getNetworkInterface): Likewise.
(setLoopback): Likewise.
(getLoopback): Likewise.
(setTTL): Likewise.
(setTimeToLive): Likewise.
(joinGroup): Likewise.
(leaveGroup): Likewise.
(send): Likewise.
2003-11-26 Michael Koch <konqueror@gmx.de>
* java/net/Socket.java * java/net/Socket.java
(implCreated): Dont set default value explicitely, added (implCreated): Dont set default value explicitely, added
documentation. documentation.
......
...@@ -67,10 +67,6 @@ import java.util.Enumeration; ...@@ -67,10 +67,6 @@ import java.util.Enumeration;
*/ */
public class MulticastSocket extends DatagramSocket public class MulticastSocket extends DatagramSocket
{ {
// FIXME: the local addr bound to the multicast socket can be reused;
// unlike unicast sockets. It binds to any available network interface.
// See p.1159 JCL book.
/** /**
* Create a MulticastSocket that this not bound to any address * Create a MulticastSocket that this not bound to any address
* *
...@@ -128,7 +124,7 @@ public class MulticastSocket extends DatagramSocket ...@@ -128,7 +124,7 @@ public class MulticastSocket extends DatagramSocket
if (isClosed()) if (isClosed())
throw new SocketException("socket is closed"); throw new SocketException("socket is closed");
return (InetAddress) impl.getOption(SocketOptions.IP_MULTICAST_IF); return (InetAddress) getImpl().getOption(SocketOptions.IP_MULTICAST_IF);
} }
/** /**
...@@ -152,7 +148,7 @@ public class MulticastSocket extends DatagramSocket ...@@ -152,7 +148,7 @@ public class MulticastSocket extends DatagramSocket
// Use getTTL here rather than getTimeToLive in case we're using an impl // Use getTTL here rather than getTimeToLive in case we're using an impl
// other than the default PlainDatagramSocketImpl and it doesn't have // other than the default PlainDatagramSocketImpl and it doesn't have
// getTimeToLive yet. // getTimeToLive yet.
return impl.getTTL(); return getImpl().getTTL();
} }
/** /**
...@@ -170,7 +166,7 @@ public class MulticastSocket extends DatagramSocket ...@@ -170,7 +166,7 @@ public class MulticastSocket extends DatagramSocket
if (isClosed()) if (isClosed())
throw new SocketException("socket is closed"); throw new SocketException("socket is closed");
return impl.getTimeToLive(); return getImpl().getTimeToLive();
} }
/** /**
...@@ -187,7 +183,7 @@ public class MulticastSocket extends DatagramSocket ...@@ -187,7 +183,7 @@ public class MulticastSocket extends DatagramSocket
if (isClosed()) if (isClosed())
throw new SocketException("socket is closed"); throw new SocketException("socket is closed");
impl.setOption(SocketOptions.IP_MULTICAST_IF, addr); getImpl().setOption(SocketOptions.IP_MULTICAST_IF, addr);
} }
/** /**
...@@ -210,10 +206,10 @@ public class MulticastSocket extends DatagramSocket ...@@ -210,10 +206,10 @@ public class MulticastSocket extends DatagramSocket
Enumeration e = netIf.getInetAddresses (); Enumeration e = netIf.getInetAddresses ();
if (!e.hasMoreElements ()) if (!e.hasMoreElements ())
throw new SocketException ("MulticastSocket: Error"); throw new SocketException("no network devices found");
InetAddress address = (InetAddress) e.nextElement (); InetAddress address = (InetAddress) e.nextElement ();
impl.setOption (SocketOptions.IP_MULTICAST_IF, address); getImpl().setOption (SocketOptions.IP_MULTICAST_IF, address);
} }
/** /**
...@@ -234,7 +230,7 @@ public class MulticastSocket extends DatagramSocket ...@@ -234,7 +230,7 @@ public class MulticastSocket extends DatagramSocket
throw new SocketException("socket is closed"); throw new SocketException("socket is closed");
InetAddress address = InetAddress address =
(InetAddress) impl.getOption (SocketOptions.IP_MULTICAST_IF); (InetAddress) getImpl().getOption (SocketOptions.IP_MULTICAST_IF);
NetworkInterface netIf = NetworkInterface.getByInetAddress (address); NetworkInterface netIf = NetworkInterface.getByInetAddress (address);
return netIf; return netIf;
...@@ -259,7 +255,7 @@ public class MulticastSocket extends DatagramSocket ...@@ -259,7 +255,7 @@ public class MulticastSocket extends DatagramSocket
if (isClosed()) if (isClosed())
throw new SocketException("socket is closed"); throw new SocketException("socket is closed");
impl.setOption (SocketOptions.IP_MULTICAST_LOOP, new Boolean (disable)); getImpl().setOption (SocketOptions.IP_MULTICAST_LOOP, new Boolean (disable));
} }
/** /**
...@@ -274,12 +270,12 @@ public class MulticastSocket extends DatagramSocket ...@@ -274,12 +270,12 @@ public class MulticastSocket extends DatagramSocket
if (isClosed()) if (isClosed())
throw new SocketException("socket is closed"); throw new SocketException("socket is closed");
Object obj = impl.getOption (SocketOptions.IP_MULTICAST_LOOP); Object buf = getImpl().getOption (SocketOptions.IP_MULTICAST_LOOP);
if (obj instanceof Boolean) if (buf instanceof Boolean)
return ((Boolean) obj).booleanValue (); return ((Boolean) buf).booleanValue();
else
throw new SocketException ("Unexpected type"); throw new SocketException("unexpected type");
} }
/** /**
...@@ -302,7 +298,7 @@ public class MulticastSocket extends DatagramSocket ...@@ -302,7 +298,7 @@ public class MulticastSocket extends DatagramSocket
// Use setTTL here rather than setTimeToLive in case we're using an impl // Use setTTL here rather than setTimeToLive in case we're using an impl
// other than the default PlainDatagramSocketImpl and it doesn't have // other than the default PlainDatagramSocketImpl and it doesn't have
// setTimeToLive yet. // setTimeToLive yet.
impl.setTTL(ttl); getImpl().setTTL(ttl);
} }
/** /**
...@@ -323,7 +319,7 @@ public class MulticastSocket extends DatagramSocket ...@@ -323,7 +319,7 @@ public class MulticastSocket extends DatagramSocket
if (ttl <= 0 || ttl > 255) if (ttl <= 0 || ttl > 255)
throw new IllegalArgumentException("Invalid ttl: " + ttl); throw new IllegalArgumentException("Invalid ttl: " + ttl);
impl.setTimeToLive(ttl); getImpl().setTimeToLive(ttl);
} }
/** /**
...@@ -347,7 +343,7 @@ public class MulticastSocket extends DatagramSocket ...@@ -347,7 +343,7 @@ public class MulticastSocket extends DatagramSocket
if (s != null) if (s != null)
s.checkMulticast(mcastaddr); s.checkMulticast(mcastaddr);
impl.join(mcastaddr); getImpl().join(mcastaddr);
} }
/** /**
...@@ -371,7 +367,7 @@ public class MulticastSocket extends DatagramSocket ...@@ -371,7 +367,7 @@ public class MulticastSocket extends DatagramSocket
if (s != null) if (s != null)
s.checkMulticast(mcastaddr); s.checkMulticast(mcastaddr);
impl.leave(mcastaddr); getImpl().leave(mcastaddr);
} }
/** /**
...@@ -410,7 +406,7 @@ public class MulticastSocket extends DatagramSocket ...@@ -410,7 +406,7 @@ public class MulticastSocket extends DatagramSocket
if (s != null) if (s != null)
s.checkMulticast (tmp.getAddress ()); s.checkMulticast (tmp.getAddress ());
impl.joinGroup (mcastaddr, netIf); getImpl().joinGroup (mcastaddr, netIf);
} }
/** /**
...@@ -445,7 +441,7 @@ public class MulticastSocket extends DatagramSocket ...@@ -445,7 +441,7 @@ public class MulticastSocket extends DatagramSocket
if (s != null) if (s != null)
s.checkMulticast (tmp.getAddress ()); s.checkMulticast (tmp.getAddress ());
impl.leaveGroup (mcastaddr, netIf); getImpl().leaveGroup (mcastaddr, netIf);
} }
/** /**
...@@ -479,9 +475,9 @@ public class MulticastSocket extends DatagramSocket ...@@ -479,9 +475,9 @@ public class MulticastSocket extends DatagramSocket
s.checkConnect(addr.getHostAddress(), p.getPort()); s.checkConnect(addr.getHostAddress(), p.getPort());
} }
int oldttl = impl.getTimeToLive(); int oldttl = getImpl().getTimeToLive();
impl.setTimeToLive(((int) ttl) & 0xFF); getImpl().setTimeToLive(((int) ttl) & 0xFF);
impl.send(p); getImpl().send(p);
impl.setTimeToLive(oldttl); getImpl().setTimeToLive(oldttl);
} }
} // class MulticastSocket } // class MulticastSocket
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment