From: <ls...@us...> - 2009-03-19 18:13:43
|
Revision: 5119 http://jnode.svn.sourceforge.net/jnode/?rev=5119&view=rev Author: lsantha Date: 2009-03-19 18:13:36 +0000 (Thu, 19 Mar 2009) Log Message: ----------- OpenJDK integration. Modified Paths: -------------- trunk/all/conf/openjdk-annotations.properties trunk/core/src/openjdk/java/java/net/AbstractPlainSocketImpl.java Added Paths: ----------- trunk/core/src/classpath/vm/java/net/MimeTypeMapper.java trunk/core/src/openjdk/java/java/net/DatagramSocket.java trunk/core/src/openjdk/java/java/net/InterfaceAddress.java trunk/core/src/openjdk/java/java/net/MulticastSocket.java trunk/core/src/openjdk/java/java/net/NetworkInterface.java trunk/core/src/openjdk/java/java/net/ServerSocket.java trunk/core/src/openjdk/java/java/net/Socket.java trunk/core/src/openjdk/java/java/net/SocketInputStream.java trunk/core/src/openjdk/java/java/net/SocketOutputStream.java trunk/core/src/openjdk/java/java/net/SocksSocketImpl.java trunk/core/src/openjdk/svm/java/net/ trunk/core/src/openjdk/svm/java/net/DefaultDatagramSocketImplFactory.java trunk/core/src/openjdk/svm/java/net/PlainDatagramSocketImpl.java trunk/core/src/openjdk/svm/java/net/PlainSocketImpl.java trunk/core/src/openjdk/vm/java/net/NativeNetworkInterface.java trunk/core/src/openjdk/vm/java/net/NativePlainDatagramSocketImpl.java trunk/core/src/openjdk/vm/java/net/NativePlainSocketImpl.java trunk/core/src/openjdk/vm/java/net/NativeSocketInputStream.java trunk/core/src/openjdk/vm/java/net/NativeSocketOutputStream.java Removed Paths: ------------- trunk/core/src/classpath/java/java/net/DatagramSocket.java trunk/core/src/classpath/java/java/net/MimeTypeMapper.java trunk/core/src/classpath/java/java/net/MulticastSocket.java trunk/core/src/classpath/java/java/net/NetworkInterface.java trunk/core/src/classpath/java/java/net/ServerSocket.java trunk/core/src/classpath/java/java/net/Socket.java Modified: trunk/all/conf/openjdk-annotations.properties =================================================================== --- trunk/all/conf/openjdk-annotations.properties 2009-03-19 16:23:45 UTC (rev 5118) +++ trunk/all/conf/openjdk-annotations.properties 2009-03-19 18:13:36 UTC (rev 5119) @@ -12,6 +12,11 @@ java/lang/ThreadLocal.class=SharedStatics java/lang/Throwable.class=MagicPermission java/net/InetAddress.class=SharedStatics +# TODO DatagramSocket, ServerSocket and Socket might need to be isolated +# TODO for propperly supporting setSocketImplFactory() +java/net/DatagramSocket.class=SharedStatics +java/net/ServerSocket.class=SharedStatics +java/net/Socket.class=SharedStatics java/net/URLConnection.class=SharedStatics java/util/Currency.class=SharedStatics java/util/concurrent/locks/LockSupport.class=SharedStatics Deleted: trunk/core/src/classpath/java/java/net/DatagramSocket.java =================================================================== --- trunk/core/src/classpath/java/java/net/DatagramSocket.java 2009-03-19 16:23:45 UTC (rev 5118) +++ trunk/core/src/classpath/java/java/net/DatagramSocket.java 2009-03-19 18:13:36 UTC (rev 5119) @@ -1,948 +0,0 @@ -/* DatagramSocket.java -- A class to model UDP sockets - Copyright (C) 1998, 1999, 2000, 2002, 2003, 2004, 2005 - Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package java.net; - -import gnu.classpath.SystemProperties; - -import gnu.java.net.PlainDatagramSocketImpl; -import gnu.java.nio.DatagramChannelImpl; -import gnu.java.security.action.GetPropertyAction; - -import java.io.IOException; -import java.nio.channels.DatagramChannel; -import java.nio.channels.IllegalBlockingModeException; -import java.security.AccessController; -import org.jnode.vm.annotation.SharedStatics; - -/** - * Written using on-line Java Platform 1.2 API Specification, as well - * as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998). - * Status: Believed complete and correct. - */ -/** - * This class models a connectionless datagram socket that sends - * individual packets of data across the network. In the TCP/IP world, - * this means UDP. Datagram packets do not have guaranteed delivery, - * or any guarantee about the order the data will be received on the - * remote host. - * - * @author Aaron M. Renn (ar...@ur...) - * @author Warren Levy (wa...@cy...) - * @date May 3, 1999. - */ -@SharedStatics -public class DatagramSocket -{ - /** - * This is the user DatagramSocketImplFactory for this class. If this - * variable is null, a default factory is used. - */ - private static DatagramSocketImplFactory factory; - - /** - * This is the implementation object used by this socket. - */ - private DatagramSocketImpl impl; - - /** - * True if socket implementation was created. - */ - private boolean implCreated; - - /** - * This is the address we are "connected" to - */ - private InetAddress remoteAddress; - - /** - * This is the port we are "connected" to - */ - private int remotePort = -1; - - /** - * True if socket is bound. - */ - private boolean bound; - - /** - * Creates a <code>DatagramSocket</code> from a specified - * <code>DatagramSocketImpl</code> instance - * - * @param impl The <code>DatagramSocketImpl</code> the socket will be - * created from - * - * @since 1.4 - */ - protected DatagramSocket(DatagramSocketImpl impl) - { - if (impl == null) - throw new NullPointerException("impl may not be null"); - - this.impl = impl; - this.remoteAddress = null; - this.remotePort = -1; - } - - /** - * Initializes a new instance of <code>DatagramSocket</code> that binds to - * a random port and every address on the local machine. - * - * @exception SocketException If an error occurs. - * @exception SecurityException If a security manager exists and - * its <code>checkListen</code> method doesn't allow the operation. - */ - public DatagramSocket() throws SocketException - { - this(new InetSocketAddress(0)); - } - - /** - * Initializes a new instance of <code>DatagramSocket</code> that binds to - * the specified port and every address on the local machine. - * - * @param port The local port number to bind to. - * - * @exception SecurityException If a security manager exists and its - * <code>checkListen</code> method doesn't allow the operation. - * @exception SocketException If an error occurs. - */ - public DatagramSocket(int port) throws SocketException - { - this(new InetSocketAddress(port)); - } - - /** - * Initializes a new instance of <code>DatagramSocket</code> that binds to - * the specified local port and address. - * - * @param port The local port number to bind to. - * @param addr The local address to bind to. - * - * @exception SecurityException If a security manager exists and its - * checkListen method doesn't allow the operation. - * @exception SocketException If an error occurs. - */ - public DatagramSocket(int port, InetAddress addr) throws SocketException - { - this(new InetSocketAddress(addr, port)); - } - - /** - * Initializes a new instance of <code>DatagramSocket</code> that binds to - * the specified local port and address. - * - * @param address The local address and port number to bind to. - * - * @exception SecurityException If a security manager exists and its - * <code>checkListen</code> method doesn't allow the operation. - * @exception SocketException If an error occurs. - * - * @since 1.4 - */ - public DatagramSocket(SocketAddress address) throws SocketException - { - // @classpath-bugfix Security - //String propVal = SystemProperties.getProperty("impl.prefix"); - //if (propVal == null || propVal.equals("")) - String propVal = (String)AccessController.doPrivileged(new GetPropertyAction("impl.prefix")); - // @classpath-bugfix-end - - // @classpath-bugfix Use factory - //if (propVal == null || propVal.equals("")) - if (factory != null) { - impl = factory.createDatagramSocketImpl(); - } else if (propVal == null || propVal.equals("")) - // @classpath-bugfix-end - impl = new PlainDatagramSocketImpl(); - else - try - { - impl = - (DatagramSocketImpl) Class.forName("java.net." + propVal - + "DatagramSocketImpl") - .newInstance(); - } - catch (Exception e) - { - System.err.println("Could not instantiate class: java.net." - + propVal + "DatagramSocketImpl"); - impl = new PlainDatagramSocketImpl(); - } - - if (address != null) - bind(address); - } - - // This needs to be accessible from java.net.MulticastSocket - DatagramSocketImpl getImpl() throws SocketException - { - try - { - if (! implCreated) - { - impl.create(); - implCreated = true; - } - - return impl; - } - catch (IOException e) - { - SocketException se = new SocketException(); - se.initCause(e); - throw se; - } - } - - /** - * Closes this datagram socket. - */ - public void close() - { - if (isClosed()) - return; - - try - { - getImpl().close(); - } - catch (SocketException e) - { - // Ignore this case, just close the socket in finally clause. - } - finally - { - remoteAddress = null; - remotePort = -1; - impl = null; - } - - try - { - if (getChannel() != null) - getChannel().close(); - } - catch (IOException e) - { - // Do nothing. - } - } - - /** - * This method returns the remote address to which this socket is - * connected. If this socket is not connected, then this method will - * return <code>null</code>. - * - * @return The remote address. - * - * @since 1.2 - */ - public InetAddress getInetAddress() - { - return remoteAddress; - } - - /** - * This method returns the remote port to which this socket is - * connected. If this socket is not connected, then this method will - * return -1. - * - * @return The remote port. - * - * @since 1.2 - */ - public int getPort() - { - return remotePort; - } - - /** - * Returns the local address this datagram socket is bound to. - * - * @return The local address is the socket is bound or null - * - * @since 1.1 - */ - public InetAddress getLocalAddress() - { - if (! isBound()) - return null; - - InetAddress localAddr; - - try - { - localAddr = - (InetAddress) getImpl().getOption(SocketOptions.SO_BINDADDR); - - SecurityManager s = System.getSecurityManager(); - if (s != null) - s.checkConnect(localAddr.getHostName(), -1); - } - catch (SecurityException e) - { - localAddr = NativeInetAddress.ANY_IF; - } - catch (SocketException e) - { - // This cannot happen as we are bound. - return null; - } - - return localAddr; - } - - /** - * Returns the local port this socket is bound to. - * - * @return The local port number. - */ - public int getLocalPort() - { - if (isClosed()) - return -1; - - try - { - return getImpl().getLocalPort(); - } - catch (SocketException e) - { - // This cannot happen as we are bound. - return 0; - } - } - - /** - * Returns the value of the socket's SO_TIMEOUT setting. If this method - * returns 0 then SO_TIMEOUT is disabled. - * - * @return The current timeout in milliseconds. - * - * @exception SocketException If an error occurs. - * - * @since 1.1 - */ - public synchronized int getSoTimeout() throws SocketException - { - if (isClosed()) - throw new SocketException("socket is closed"); - - Object buf = getImpl().getOption(SocketOptions.SO_TIMEOUT); - - if (buf instanceof Integer) - return ((Integer) buf).intValue(); - - throw new SocketException("unexpected type"); - } - - /** - * Sets the value of the socket's SO_TIMEOUT value. A value of 0 will - * disable SO_TIMEOUT. Any other value is the number of milliseconds - * a socket read/write will block before timing out. - * - * @param timeout The new SO_TIMEOUT value in milliseconds. - * - * @exception SocketException If an error occurs. - * - * @since 1.1 - */ - public synchronized void setSoTimeout(int timeout) throws SocketException - { - if (isClosed()) - throw new SocketException("socket is closed"); - - if (timeout < 0) - throw new IllegalArgumentException("Invalid timeout: " + timeout); - - getImpl().setOption(SocketOptions.SO_TIMEOUT, new Integer(timeout)); - } - - /** - * This method returns the value of the system level socket option - * SO_SNDBUF, which is used by the operating system to tune buffer - * sizes for data transfers. - * - * @return The send buffer size. - * - * @exception SocketException If an error occurs. - * - * @since 1.2 - */ - public int getSendBufferSize() throws SocketException - { - if (isClosed()) - throw new SocketException("socket is closed"); - - Object buf = getImpl().getOption(SocketOptions.SO_SNDBUF); - - if (buf instanceof Integer) - return ((Integer) buf).intValue(); - - throw new SocketException("unexpected type"); - } - - /** - * This method sets the value for the system level socket option - * SO_SNDBUF to the specified value. Note that valid values for this - * option are specific to a given operating system. - * - * @param size The new send buffer size. - * - * @exception SocketException If an error occurs. - * @exception IllegalArgumentException If size is 0 or negative. - * - * @since 1.2 - */ - public void setSendBufferSize(int size) throws SocketException - { - if (isClosed()) - throw new SocketException("socket is closed"); - - if (size < 0) - throw new IllegalArgumentException("Buffer size is less than 0"); - - getImpl().setOption(SocketOptions.SO_SNDBUF, new Integer(size)); - } - - /** - * This method returns the value of the system level socket option - * SO_RCVBUF, which is used by the operating system to tune buffer - * sizes for data transfers. - * - * @return The receive buffer size. - * - * @exception SocketException If an error occurs. - * - * @since 1.2 - */ - public int getReceiveBufferSize() throws SocketException - { - if (isClosed()) - throw new SocketException("socket is closed"); - - Object buf = getImpl().getOption(SocketOptions.SO_RCVBUF); - - if (buf instanceof Integer) - return ((Integer) buf).intValue(); - - throw new SocketException("unexpected type"); - } - - /** - * This method sets the value for the system level socket option - * SO_RCVBUF to the specified value. Note that valid values for this - * option are specific to a given operating system. - * - * @param size The new receive buffer size. - * - * @exception SocketException If an error occurs. - * @exception IllegalArgumentException If size is 0 or negative. - * - * @since 1.2 - */ - public void setReceiveBufferSize(int size) throws SocketException - { - if (isClosed()) - throw new SocketException("socket is closed"); - - if (size < 0) - throw new IllegalArgumentException("Buffer size is less than 0"); - - getImpl().setOption(SocketOptions.SO_RCVBUF, new Integer(size)); - } - - /** - * This method connects this socket to the specified address and port. - * When a datagram socket is connected, it will only send or receive - * packets to and from the host to which it is connected. A multicast - * socket that is connected may only send and not receive packets. - * - * @param address The address to connect this socket to. - * @param port The port to connect this socket to. - * - * @exception SocketException If an error occurs. - * @exception IllegalArgumentException If address or port are invalid. - * @exception SecurityException If the caller is not allowed to send - * datagrams to or receive from this address and port. - * - * @since 1.2 - */ - public void connect(InetAddress address, int port) - { - if (address == null) - throw new IllegalArgumentException("Connect address may not be null"); - - if ((port < 1) || (port > 65535)) - throw new IllegalArgumentException("Port number is illegal: " + port); - - SecurityManager sm = System.getSecurityManager(); - if (sm != null) - sm.checkConnect(address.getHostName(), port); - - try - { - getImpl().connect(address, port); - remoteAddress = address; - remotePort = port; - } - catch (SocketException e) - { - // This means simply not connected or connect not implemented. - } - } - - /** - * This method disconnects this socket from the address/port it was - * connected to. If the socket was not connected in the first place, - * this method does nothing. - * - * @since 1.2 - */ - public void disconnect() - { - if (! isConnected()) - return; - - try - { - getImpl().disconnect(); - } - catch (SocketException e) - { - // This cannot happen as we are connected. - } - finally - { - remoteAddress = null; - remotePort = -1; - } - } - - /** - * Reads a datagram packet from the socket. Note that this method - * will block until a packet is received from the network. On return, - * the passed in <code>DatagramPacket</code> is populated with the data - * received and all the other information about the packet. - * - * @param p A <code>DatagramPacket</code> for storing the data - * - * @exception IOException If an error occurs. - * @exception SocketTimeoutException If setSoTimeout was previously called - * and the timeout has expired. - * @exception PortUnreachableException If the socket is connected to a - * currently unreachable destination. Note, there is no guarantee that the - * exception will be thrown. - * @exception IllegalBlockingModeException If this socket has an associated - * channel, and the channel is in non-blocking mode. - * @exception SecurityException If a security manager exists and its - * checkAccept method doesn't allow the receive. - */ - public synchronized void receive(DatagramPacket p) throws IOException - { - if (isClosed()) - throw new SocketException("socket is closed"); - - if (remoteAddress != null && remoteAddress.isMulticastAddress()) - throw new IOException - ("Socket connected to a multicast address my not receive"); - - if (getChannel() != null && ! getChannel().isBlocking() - && ! ((DatagramChannelImpl) getChannel()).isInChannelOperation()) - throw new IllegalBlockingModeException(); - - getImpl().receive(p); - - SecurityManager s = System.getSecurityManager(); - if (s != null && isConnected()) - s.checkAccept(p.getAddress().getHostName(), p.getPort()); - } - - /** - * Sends the specified packet. The host and port to which the packet - * are to be sent should be set inside the packet. - * - * @param p The datagram packet to send. - * - * @exception IOException If an error occurs. - * @exception SecurityException If a security manager exists and its - * checkMulticast or checkConnect method doesn't allow the send. - * @exception PortUnreachableException If the socket is connected to a - * currently unreachable destination. Note, there is no guarantee that the - * exception will be thrown. - * @exception IllegalBlockingModeException If this socket has an associated - * channel, and the channel is in non-blocking mode. - */ - public void send(DatagramPacket p) throws IOException - { - if (isClosed()) - throw new SocketException("socket is closed"); - - // JDK1.2: Don't do security checks if socket is connected; see jdk1.2 api. - SecurityManager s = System.getSecurityManager(); - if (s != null && ! isConnected()) - { - InetAddress addr = p.getAddress(); - if (addr.isMulticastAddress()) - s.checkMulticast(addr); - else - s.checkConnect(addr.getHostAddress(), p.getPort()); - } - - if (isConnected()) - { - if (p.getAddress() != null - && (remoteAddress != p.getAddress() || remotePort != p.getPort())) - throw new IllegalArgumentException - ("DatagramPacket address does not match remote address"); - } - - // FIXME: if this is a subclass of MulticastSocket, - // use getTimeToLive for TTL val. - if (getChannel() != null && ! getChannel().isBlocking() - && ! ((DatagramChannelImpl) getChannel()).isInChannelOperation()) - throw new IllegalBlockingModeException(); - - getImpl().send(p); - } - - /** - * Binds the socket to the given socket address. - * - * @param address The socket address to bind to. - * - * @exception SocketException If an error occurs. - * @exception SecurityException If a security manager exists and - * its checkListen method doesn't allow the operation. - * @exception IllegalArgumentException If address type is not supported. - * - * @since 1.4 - */ - public void bind(SocketAddress address) throws SocketException - { - if (isClosed()) - throw new SocketException("socket is closed"); - - if (! (address instanceof InetSocketAddress)) - throw new IllegalArgumentException("unsupported address type"); - - InetAddress addr = ((InetSocketAddress) address).getAddress(); - int port = ((InetSocketAddress) address).getPort(); - - if (port < 0 || port > 65535) - throw new IllegalArgumentException("Invalid port: " + port); - - SecurityManager s = System.getSecurityManager(); - if (s != null) - s.checkListen(port); - - if (addr == null) - addr = NativeInetAddress.ANY_IF; - - try - { - getImpl().bind(port, addr); - bound = true; - } - catch (SocketException exception) - { - getImpl().close(); - throw exception; - } - catch (RuntimeException exception) - { - getImpl().close(); - throw exception; - } - catch (Error error) - { - getImpl().close(); - throw error; - } - } - - /** - * Checks if the datagram socket is closed. - * - * @return True if socket is closed, false otherwise. - * - * @since 1.4 - */ - public boolean isClosed() - { - return impl == null; - } - - /** - * Returns the datagram channel assoziated with this datagram socket. - * - * @return The associated <code>DatagramChannel</code> object or null - * - * @since 1.4 - */ - public DatagramChannel getChannel() - { - return null; - } - - /** - * Connects the datagram socket to a specified socket address. - * - * @param address The socket address to connect to. - * - * @exception SocketException If an error occurs. - * @exception IllegalArgumentException If address type is not supported. - * - * @since 1.4 - */ - public void connect(SocketAddress address) throws SocketException - { - if (isClosed()) - throw new SocketException("socket is closed"); - - if (! (address instanceof InetSocketAddress)) - throw new IllegalArgumentException("unsupported address type"); - - InetSocketAddress tmp = (InetSocketAddress) address; - connect(tmp.getAddress(), tmp.getPort()); - } - - /** - * Returns the binding state of the socket. - * - * @return True if socket bound, false otherwise. - * - * @since 1.4 - */ - public boolean isBound() - { - return bound; - } - - /** - * Returns the connection state of the socket. - * - * @return True if socket is connected, false otherwise. - * - * @since 1.4 - */ - public boolean isConnected() - { - return remoteAddress != null; - } - - /** - * Returns the SocketAddress of the host this socket is conneted to - * or null if this socket is not connected. - * - * @return The socket address of the remote host if connected or null - * - * @since 1.4 - */ - public SocketAddress getRemoteSocketAddress() - { - if (! isConnected()) - return null; - - return new InetSocketAddress(remoteAddress, remotePort); - } - - /** - * Returns the local SocketAddress this socket is bound to. - * - * @return The local SocketAddress or null if the socket is not bound. - * - * @since 1.4 - */ - public SocketAddress getLocalSocketAddress() - { - if (! isBound()) - return null; - - return new InetSocketAddress(getLocalAddress(), getLocalPort()); - } - - /** - * Enables/Disables SO_REUSEADDR. - * - * @param on Whether or not to have SO_REUSEADDR turned on. - * - * @exception SocketException If an error occurs. - * - * @since 1.4 - */ - public void setReuseAddress(boolean on) throws SocketException - { - if (isClosed()) - throw new SocketException("socket is closed"); - - getImpl().setOption(SocketOptions.SO_REUSEADDR, Boolean.valueOf(on)); - } - - /** - * Checks if SO_REUSEADDR is enabled. - * - * @return True if SO_REUSEADDR is set on the socket, false otherwise. - * - * @exception SocketException If an error occurs. - * - * @since 1.4 - */ - public boolean getReuseAddress() throws SocketException - { - if (isClosed()) - throw new SocketException("socket is closed"); - - Object buf = getImpl().getOption(SocketOptions.SO_REUSEADDR); - - if (buf instanceof Boolean) - return ((Boolean) buf).booleanValue(); - - throw new SocketException("unexpected type"); - } - - /** - * Enables/Disables SO_BROADCAST - * - * @param enable True if SO_BROADCAST should be enabled, false otherwise. - * - * @exception SocketException If an error occurs - * - * @since 1.4 - */ - public void setBroadcast(boolean enable) throws SocketException - { - if (isClosed()) - throw new SocketException("socket is closed"); - - getImpl().setOption(SocketOptions.SO_BROADCAST, Boolean.valueOf(enable)); - } - - /** - * Checks if SO_BROADCAST is enabled - * - * @return Whether SO_BROADCAST is set - * - * @exception SocketException If an error occurs - * - * @since 1.4 - */ - public boolean getBroadcast() throws SocketException - { - if (isClosed()) - throw new SocketException("socket is closed"); - - Object buf = getImpl().getOption(SocketOptions.SO_BROADCAST); - - if (buf instanceof Boolean) - return ((Boolean) buf).booleanValue(); - - throw new SocketException("unexpected type"); - } - - /** - * Sets the traffic class value - * - * @param tc The traffic class - * - * @exception SocketException If an error occurs - * @exception IllegalArgumentException If tc value is illegal - * - * @see DatagramSocket#getTrafficClass() - * - * @since 1.4 - */ - public void setTrafficClass(int tc) throws SocketException - { - if (isClosed()) - throw new SocketException("socket is closed"); - - if (tc < 0 || tc > 255) - throw new IllegalArgumentException(); - - getImpl().setOption(SocketOptions.IP_TOS, new Integer(tc)); - } - - /** - * Returns the current traffic class - * - * @return The current traffic class. - * - * @see DatagramSocket#setTrafficClass(int tc) - * - * @exception SocketException If an error occurs - * - * @since 1.4 - */ - public int getTrafficClass() throws SocketException - { - if (isClosed()) - throw new SocketException("socket is closed"); - - Object buf = getImpl().getOption(SocketOptions.IP_TOS); - - if (buf instanceof Integer) - return ((Integer) buf).intValue(); - - throw new SocketException("unexpected type"); - } - - /** - * Sets the datagram socket implementation factory for the application - * - * @param fac The factory to set - * - * @exception IOException If an error occurs - * @exception SocketException If the factory is already defined - * @exception SecurityException If a security manager exists and its - * checkSetFactory method doesn't allow the operation - */ - public static void setDatagramSocketImplFactory(DatagramSocketImplFactory fac) - throws IOException - { - if (factory != null) - throw new SocketException("DatagramSocketImplFactory already defined"); - - SecurityManager sm = System.getSecurityManager(); - if (sm != null) - sm.checkSetFactory(); - - factory = fac; - } -} Deleted: trunk/core/src/classpath/java/java/net/MimeTypeMapper.java =================================================================== --- trunk/core/src/classpath/java/java/net/MimeTypeMapper.java 2009-03-19 16:23:45 UTC (rev 5118) +++ trunk/core/src/classpath/java/java/net/MimeTypeMapper.java 2009-03-19 18:13:36 UTC (rev 5119) @@ -1,346 +0,0 @@ -/* MimeTypeMapper.java -- A class for mapping file names to MIME types - Copyright (C) 1998 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package java.net; - -import gnu.classpath.SystemProperties; - -import java.io.FileReader; -import java.io.IOException; -import java.io.LineNumberReader; -import java.util.Hashtable; -import java.util.Iterator; -import java.util.Map; -import java.util.NoSuchElementException; -import java.util.StringTokenizer; -import java.util.TreeMap; - - -/** - * This non-public class is used to implement the FileNameMap interface - * which defines a mechanism for mapping filenames to MIME types. - * - * @version 0.5 - * - * @author Aaron M. Renn (ar...@ur...) - */ -class MimeTypeMapper implements FileNameMap -{ - /** - * This array of strings is used to identify a MIME type based on a file - * extension. This is list is based on the Apache mime.types file. - */ - protected static final String[][] mime_strings = - { - { "ai", "application/postscript" } - , { "aif", "audio/x-aiff" } - , { "aifc", "audio/x-aiff" } - , { "aiff", "audio/x-aiff" } - , { "asc", "text/plain" } - , { "au", "audio/basic" } - , { "avi", "video/x-msvideo" } - , { "bcpio", "application/x-bcpio" } - , { "bin", "application/octet-stream" } - , { "bmp", "image/bmp" } - , { "bz2", "application/x-bzip2" } - , { "cdf", "application/x-netcdf" } - , { "chrt", "application/x-kchart" } - , { "class", "application/octet-stream" } - , { "cpio", "application/x-cpio" } - , { "cpt", "application/mac-compactpro" } - , { "csh", "application/x-csh" } - , { "css", "text/css" } - , { "dcr", "application/x-director" } - , { "dir", "application/x-director" } - , { "djv", "image/vnd.djvu" } - , { "djvu", "image/vnd.djvu" } - , { "dll", "application/octet-stream" } - , { "dms", "application/octet-stream" } - , { "doc", "application/msword" } - , { "dvi", "application/x-dvi" } - , { "dxr", "application/x-director" } - , { "eps", "application/postscript" } - , { "etx", "text/x-setext" } - , { "exe", "application/octet-stream" } - , { "ez", "application/andrew-inset" } - , { "gif", "image/gif" } - , { "gtar", "application/x-gtar" } - , { "gz", "application/x-gzip" } - , { "hdf", "application/x-hdf" } - , { "hqx", "application/mac-binhex40" } - , { "htm", "text/html" } - , { "html", "text/html" } - , { "ice", "x-conference/x-cooltalk" } - , { "ief", "image/ief" } - , { "iges", "model/iges" } - , { "igs", "model/iges" } - , { "img", "application/octet-stream" } - , { "iso", "application/octet-stream" } - , { "jpe", "image/jpeg" } - , { "jpeg", "image/jpeg" } - , { "jpg", "image/jpeg" } - , { "js", "application/x-javascript" } - , { "kar", "audio/midi" } - , { "kil", "application/x-killustrator" } - , { "kpr", "application/x-kpresenter" } - , { "kpt", "application/x-kpresenter" } - , { "ksp", "application/x-kspread" } - , { "kwd", "application/x-kword" } - , { "kwt", "application/x-kword" } - , { "latex", "application/x-latex" } - , { "lha", "application/octet-stream" } - , { "lzh", "application/octet-stream" } - , { "m3u", "audio/x-mpegurl" } - , { "man", "application/x-troff-man" } - , { "me", "application/x-troff-me" } - , { "mesh", "model/mesh" } - , { "mid", "audio/midi" } - , { "midi", "audio/midi" } - , { "mif", "application/vnd.mif" } - , { "mov", "video/quicktime" } - , { "movie", "video/x-sgi-movie" } - , { "mp2", "audio/mpeg" } - , { "mp3", "audio/mpeg" } - , { "mpe", "video/mpeg" } - , { "mpeg", "video/mpeg" } - , { "mpg", "video/mpeg" } - , { "mpga", "audio/mpeg" } - , { "ms", "application/x-troff-ms" } - , { "msh", "model/mesh" } - , { "mxu", "video/vnd.mpegurl" } - , { "nc", "application/x-netcdf" } - , { "ogg", "application/ogg" } - , { "pbm", "image/x-portable-bitmap" } - , { "pdb", "chemical/x-pdb" } - , { "pdf", "application/pdf" } - , { "pgm", "image/x-portable-graymap" } - , { "pgn", "application/x-chess-pgn" } - , { "png", "image/png" } - , { "pnm", "image/x-portable-anymap" } - , { "ppm", "image/x-portable-pixmap" } - , { "ppt", "application/vnd.ms-powerpoint" } - , { "ps", "application/postscript" } - , { "qt", "video/quicktime" } - , { "ra", "audio/x-realaudio" } - , { "ram", "audio/x-pn-realaudio" } - , { "ras", "image/x-cmu-raster" } - , { "rgb", "image/x-rgb" } - , { "rm", "audio/x-pn-realaudio" } - , { "roff", "application/x-troff" } - , { "rpm", "application/x-rpm" } - , { "rtf", "text/rtf" } - , { "rtx", "text/richtext" } - , { "sgm", "text/sgml" } - , { "sgml", "text/sgml" } - , { "sh", "application/x-sh" } - , { "shar", "application/x-shar" } - , { "silo", "model/mesh" } - , { "sit", "application/x-stuffit" } - , { "skd", "application/x-koan" } - , { "skm", "application/x-koan" } - , { "skp", "application/x-koan" } - , { "skt", "application/x-koan" } - , { "smi", "application/smil" } - , { "smil", "application/smil" } - , { "snd", "audio/basic" } - , { "so", "application/octet-stream" } - , { "spl", "application/x-futuresplash" } - , { "src", "application/x-wais-source" } - , { "stc", "application/vnd.sun.xml.calc.template" } - , { "std", "application/vnd.sun.xml.draw.template" } - , { "sti", "application/vnd.sun.xml.impress.template" } - , { "stw", "application/vnd.sun.xml.writer.template" } - , { "sv4cpio", "application/x-sv4cpio" } - , { "sv4crc", "application/x-sv4crc" } - , { "swf", "application/x-shockwave-flash" } - , { "sxc", "application/vnd.sun.xml.calc" } - , { "sxd", "application/vnd.sun.xml.draw" } - , { "sxg", "application/vnd.sun.xml.writer.global" } - , { "sxi", "application/vnd.sun.xml.impress" } - , { "sxm", "application/vnd.sun.xml.math" } - , { "sxw", "application/vnd.sun.xml.writer" } - , { "t", "application/x-troff" } - , { "tar", "application/x-tar" } - , { "tcl", "application/x-tcl" } - , { "tex", "application/x-tex" } - , { "texi", "application/x-texinfo" } - , { "texinfo", "application/x-texinfo" } - , { "tgz", "application/x-gzip" } - , { "tif", "image/tiff" } - , { "tiff", "image/tiff" } - , { "torrent", "application/x-bittorrent" } - , { "tr", "application/x-troff" } - , { "tsv", "text/tab-separated-values" } - , { "txt", "text/plain" } - , { "ustar", "application/x-ustar" } - , { "vcd", "application/x-cdlink" } - , { "vrml", "model/vrml" } - , { "wav", "audio/x-wav" } - , { "wbmp", "image/vnd.wap.wbmp" } - , { "wbxml", "application/vnd.wap.wbxml" } - , { "wml", "text/vnd.wap.wml" } - , { "wmlc", "application/vnd.wap.wmlc" } - , { "wmls", "text/vnd.wap.wmlscript" } - , { "wmlsc", "application/vnd.wap.wmlscriptc" } - , { "wrl", "model/vrml" } - , { "xbm", "image/x-xbitmap" } - , { "xht", "application/xhtml+xml" } - , { "xhtml", "application/xhtml+xml" } - , { "xls", "application/vnd.ms-excel" } - , { "xml", "text/xml" } - , { "xpm", "image/x-xpixmap" } - , { "xsl", "text/xml" } - , { "xwd", "image/x-xwindowdump" } - , { "xyz", "chemical/x-xyz" } - , { "zip", "application/zip" } - }; - - /** - * The MIME types above are put into this Hashtable for faster lookup. - */ - private Hashtable<String, String> mime_types - = new Hashtable<String, String>(150); - - /** - * Create a new <code>MimeTypeMapper</code> object. - */ - public MimeTypeMapper() - { - for (int i = 0; i < mime_strings.length; i++) - mime_types.put(mime_strings[i][0], mime_strings[i][1]); - - // Now read from the system mime database, if it exists. Entries found - // here override our internal ones. - try - { - // On Linux this usually means /etc/mime.types. - String file - = SystemProperties.getProperty("gnu.classpath.mime.types.file"); - if (file != null) - fillFromFile(mime_types, file); - } - catch (IOException ignore) - { - } - } - - public static void fillFromFile (Map<String, String> table, String fname) - throws IOException - { - LineNumberReader reader = - new LineNumberReader (new FileReader (fname)); - - while (reader.ready ()) - { - StringTokenizer tokenizer = - new StringTokenizer (reader.readLine ()); - - try - { - String t = tokenizer.nextToken (); - - if (! t.startsWith ("#")) - { - while (true) - { - // Read the next extension - String e = tokenizer.nextToken (); - if ((e != null) && (! e.startsWith ("#"))) - table.put (e, t); - else - break; - } - } - } - catch (NoSuchElementException ex) - { - // Do nothing. - } - } - } - - /** - * The method returns the MIME type of the filename passed as an argument. - * The value returned is based on the extension of the filename. The - * default content type returned if this method cannot determine the - * actual content type is "application/octet-stream" - * - * @param filename The name of the file to return the MIME type for - * - * @return The MIME type - */ - public String getContentTypeFor(String filename) - { - int index = filename.lastIndexOf("."); - if (index != -1) - { - if (index == filename.length()) - return "application/octet-stream"; - else - filename = filename.substring(index + 1); - } - - String type = (String) mime_types.get(filename); - if (type == null) - return "application/octet-stream"; - else - return type; - } - - /** - * Run this class as a program to create a new mime_strings table. - */ - public static void main(String[] args) throws IOException - { - TreeMap<String, String> map = new TreeMap<String, String>(); - // It is fine to hard-code the name here. This is only ever - // used by maintainers, who can hack it if they need to re-run - // it. - fillFromFile(map, "/etc/mime.types"); - Iterator<String> it = map.keySet().iterator(); - boolean first = true; - while (it.hasNext()) - { - String key = it.next(); - String value = map.get(key); - // Put the "," first since it is easier to make correct syntax this way. - System.out.println(" " + (first ? " " : ", ") - + "{ \"" + key + "\", \"" + value + "\" }"); - first = false; - } - } -} Deleted: trunk/core/src/classpath/java/java/net/MulticastSocket.java =================================================================== --- trunk/core/src/classpath/java/java/net/MulticastSocket.java 2009-03-19 16:23:45 UTC (rev 5118) +++ trunk/core/src/classpath/java/java/net/MulticastSocket.java 2009-03-19 18:13:36 UTC (rev 5119) @@ -1,490 +0,0 @@ -/* MulticastSocket.java -- Class for using multicast sockets - Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 - Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package java.net; - -import java.io.IOException; -import java.util.Enumeration; - - -/** - * Written using on-line Java Platform 1.2 API Specification, as well - * as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998). - * Status: Believed complete and correct. - */ -/** - * This class models a multicast UDP socket. A multicast address is a - * class D internet address (one whose most significant bits are 1110). - * A multicast group consists of a multicast address and a well known - * port number. All members of the group listening on that address and - * port will receive all the broadcasts to the group. - * <p> - * Please note that applets are not allowed to use multicast sockets - * - * Written using on-line Java Platform 1.2 API Specification, as well - * as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998). - * Status: Believed complete and correct. - * - * @author Warren Levy (wa...@cy...) - * @author Aaron M. Renn (ar...@ur...) (Documentation comments) - * @since 1.1 - * @date May 18, 1999. - */ -public class MulticastSocket extends DatagramSocket -{ - /** - * Create a MulticastSocket that this not bound to any address - * - * @exception IOException If an error occurs - * @exception SecurityException If a security manager exists and its - * checkListen method doesn't allow the operation - */ - public MulticastSocket() throws IOException - { - this(new InetSocketAddress(0)); - } - - /** - * Create a multicast socket bound to the specified port - * - * @param port The port to bind to - * - * @exception IOException If an error occurs - * @exception SecurityException If a security manager exists and its - * checkListen method doesn't allow the operation - */ - public MulticastSocket(int port) throws IOException - { - this(new InetSocketAddress(port)); - } - - /** - * Create a multicast socket bound to the specified SocketAddress. - * - * @param address The SocketAddress the multicast socket will be bound to - * - * @exception IOException If an error occurs - * @exception SecurityException If a security manager exists and its - * checkListen method doesn't allow the operation - * - * @since 1.4 - */ - public MulticastSocket(SocketAddress address) throws IOException - { - super((SocketAddress) null); - setReuseAddress(true); - if (address != null) - bind(address); - } - - /** - * Returns the interface being used for multicast packets - * - * @return The multicast interface - * - * @exception SocketException If an error occurs - */ - public InetAddress getInterface() throws SocketException - { - if (isClosed()) - throw new SocketException("socket is closed"); - - return (InetAddress) getImpl().getOption(SocketOptions.IP_MULTICAST_IF); - } - - /** - * Returns the current value of the "Time to Live" option. This is the - * number of hops a packet can make before it "expires". This method id - * deprecated. Use <code>getTimeToLive</code> instead. - * - * @return The TTL value - * - * @exception IOException If an error occurs - * - * @deprecated 1.2 Replaced by getTimeToLive() - * - * @see MulticastSocket#getTimeToLive() - */ - public byte getTTL() throws IOException - { - if (isClosed()) - throw new SocketException("socket is closed"); - - // 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 getImpl().getTTL(); - } - - /** - * Returns the current value of the "Time to Live" option. This is the - * number of hops a packet can make before it "expires". - * - * @return The TTL value - * - * @exception IOException If an error occurs - * - * @since 1.2 - */ - public int getTimeToLive() throws IOException - { - if (isClosed()) - throw new SocketException("socket is closed"); - - return getImpl().getTimeToLive(); - } - - /** - * Sets the interface to use for sending multicast packets. - * - * @param addr The new interface to use. - * - * @exception SocketException If an error occurs. - * - * @since 1.4 - */ - public void setInterface(InetAddress addr) throws SocketException - { - if (isClosed()) - throw new SocketException("socket is closed"); - - getImpl().setOption(SocketOptions.IP_MULTICAST_IF, addr); - } - - /** - * Sets the local network interface used to send multicast messages - * - * @param netIf The local network interface used to send multicast messages - * - * @exception SocketException If an error occurs - * - * @see MulticastSocket#getNetworkInterface() - * - * @since 1.4 - */ - public void setNetworkInterface(NetworkInterface netIf) - throws SocketException - { - if (isClosed()) - throw new SocketException("socket is closed"); - - // @vm-specific Set network interface via extended option - getImpl().setOption(ExSocketOptions.SO_TRANSMIT_IF, netIf); -/* - Enumeration e = netIf.getInetAddresses(); - - if (! e.hasMoreElements()) - throw new SocketException("no network devices found"); - - InetAddress address = (InetAddress) e.nextElement(); - getImpl().setOption(SocketOptions.IP_MULTICAST_IF, address); -*/ - } - - /** - * Gets the local network interface which is used to send multicast messages - * - * @return The local network interface to send multicast messages - * - * @exception SocketException If an error occurs - * - * @see MulticastSocket#setNetworkInterface(NetworkInterface netIf) - * - * @since 1.4 - */ - public NetworkInterface getNetworkInterface() throws SocketException - { - if (isClosed()) - throw new SocketException("socket is closed"); - - InetAddress address = - (InetAddress) getImpl().getOption(SocketOptions.IP_MULTICAST_IF); - NetworkInterface netIf = NetworkInterface.getByInetAddress(address); - - return netIf; - } - - /** - * Disable/Enable local loopback of multicast packets. The option is used by - * the platform's networking code as a hint for setting whether multicast - * data will be looped back to the local socket. - * - * Because this option is a hint, applications that want to verify what - * loopback mode is set to should call #getLoopbackMode - * - * @param disable True to disable loopback mode - * - * @exception SocketException If an error occurs - * - * @since 1.4 - */ - public void setLoopbackMode(boolean disable) throws SocketException - { - if (isClosed()) - throw new SocketException("socket is closed"); - - getImpl().setOption(SocketOptions.IP_MULTICAST_LOOP, - Boolean.valueOf(disable)); - } - - /** - * Checks if local loopback mode is enabled - * - * @return true if loopback mode is enabled, false otherwise - * - * @exception SocketException If an error occurs - * - * @since 1.4 - */ - public boolean getLoopbackMode() throws SocketException - { - if (isClosed()) - throw new SocketException("socket is closed"); - - Object buf = getImpl().getOption(SocketOptions.IP_MULTICAST_LOOP); - - if (buf instanceof Boolean) - return ((Boolean) buf).booleanValue(); - - throw new SocketException("unexpected type"); - } - - /** - * Sets the "Time to Live" value for a socket. The value must be between - * 1 and 255. - * - * @param ttl The new TTL value - * - * @exception IOException If an error occurs - * - * @deprecated 1.2 Replaced by <code>setTimeToLive</code> - * - * @see MulticastSocket#setTimeToLive(int ttl) - */ - public void setTTL(byte ttl) throws IOException - { - if (isClosed()) - throw new SocketException("socket is closed"); - - // 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. - getImpl().setTTL(ttl); - } - - /** - * Sets the "Time to Live" value for a socket. The value must be between - * 1 and 255. - * - * @param ttl The new TTL value - * - * @exception IOException If an error occurs - * - * @since 1.2 - */ - public void setTimeToLive(int ttl) throws IOException - { - if (isClosed()) - throw new SocketException("socket is closed"); - - if (ttl <= 0 || ttl > 255) - throw new IllegalArgumentException("Invalid ttl: " + ttl); - - getImpl().setTimeToLive(ttl); - } - - /** - * Joins the specified multicast group. - * - * @param mcastaddr The address of the group to join - * - * @exception IOException If an error occurs - * @exception SecurityException If a security manager exists and its - * checkMulticast method doesn't allow the operation - */ - public void joinGroup(InetAddress mcastaddr) throws IOException - { - if (isClosed()) - throw new SocketException("socket is closed"); - - if (! mcastaddr.isMulticastAddress()) - throw new IOException("Not a Multicast address"); - - SecurityManager s = System.getSecurityManager(); - if (s != null) - s.checkMulticast(mcastaddr); - - getImpl().join(mcastaddr); - } - - /** - * Leaves the specified multicast group - * - * @param mcastaddr The address of the group to leave - * - * @exception IOException If an error occurs - * @exception SecurityException If a security manager exists and its - * checkMulticast method doesn't allow the operation - */ - public void leaveGroup(InetAddress mcastaddr) throws IOException - { - if (isClosed()) - throw new SocketException("socket is closed"); - - if (! mcastaddr.isMulticastAddress()) - throw new IOException("Not a Multicast address"); - - SecurityManager s = System.getSecurityManager(); - if (s != null) - s.checkMulticast(mcastaddr); - - getImpl().leave(mcastaddr); - } - - /** - * Joins the specified mulitcast group on a specified interface. - * - * @param mcastaddr The multicast address to join - * @param netIf The local network interface to receive the multicast - * messages on or null to defer the interface set by #setInterface or - * #setNetworkInterface - * - * @exception IOException If an error occurs - * @exception IllegalArgumentException If address type is not supported - * @exception SecurityException If a security manager exists and its - * checkMulticast method doesn't allow the operation - * - * @see MulticastSocket#setInterface(InetAddress addr) - * @see MulticastSocket#setNetworkInterface(NetworkInterface netIf) - * - * @since 1.4 - */ - public void joinGroup(SocketAddress mcastaddr, NetworkInterface netIf) - throws IOException - { - if (isClosed()) - throw new SocketException("socket is closed"); - - if (! (mcastaddr instanceof InetSocketAddress)) - throw new IllegalArgumentException("SocketAddress type not supported"); - - InetSocketAddress tmp = (InetSocketAddress) mcastaddr; - - if (! tmp.getAddress().isMulticastAddress()) - throw new IOException("Not a Multicast address"); - - SecurityManager s = System.getSecurityManager(); - if (s != null) - s.checkMulticast(tmp.getAddress()); - - getImpl().joinGroup(mcastaddr, netIf); - } - - /** - * Leaves the specified mulitcast group on a specified interface. - * - * @param mcastaddr The multicast address to leave - * @param netIf The local networki interface or null to defer to the - * interface set by setInterface or setNetworkInterface - * - * @exception IOException If an error occurs - * @exception IllegalArgumentException If address type is not supported - * @exception SecurityException If a security manager exists and its - * checkMulticast method doesn't allow the operation - * - * @see MulticastSocket#setInterface(InetAddress addr) - * @see MulticastSocket#setNetworkInterface(NetworkInterface netIf) - * - * @since 1.4 - */ - public void leaveGroup(SocketAddress mcastaddr, NetworkInterface netIf) - throws IOException - { - if (isClosed()) - throw new SocketException("socket is closed"); - - InetSocketAddress tmp = (InetSocketAddress) mcastaddr; - - if (! tmp.getAddress().isMulticastAddress()) - throw new IOException("Not a Multicast address"); - - SecurityManager s = System.getSecurityManager(); - if (s != null) - s.checkMulticast(tmp.getAddress()); - - getImpl().leaveGroup(mcastaddr, netIf); - } - - /** - * Sends a packet of data to a multicast address with a TTL that is - * different from the default TTL on this socket. The default TTL for - * the socket is not changed. - * - * @param packet The packet of data to send - * @param ttl The TTL for this packet - * - * @exception IOException If an error occurs - * @exception SecurityException If a security manager exists and its - * checkConnect or checkMulticast method doesn't allow the operation - * - * @deprecated - */ - public synchronized void send(DatagramPacket packet, byte ttl) - throws IOException - { - if (isClosed()) - throw new SocketException("socket is closed"); - - SecurityManager s = System.getSecurityManager(); - if (s != null) - { - InetAddress addr = packet.getAddress(); - if (addr.isMulticastAddress()) - s.checkPermission(new SocketPermission(addr.getHostName() - + packet.getPort(), - "accept,connect")); - else - s.checkConnect(addr.getHostAddress(), packet.getPort()); - } - - int oldttl = getImpl().getTimeToLive(); - getImpl().setTimeToLive(((int) ttl) & 0xFF); - getImpl().send(packet); - getImpl().setTimeToLive(oldttl); - } -} Deleted: trunk/core/src/classpath/java/java/net/NetworkInterface.java =================================================================== --- trunk/core/src/classpath/java/java/net/NetworkInterface.java 2009-03-19 16:23:45 UTC (rev 5118) +++ trunk/core/src/classpath/java/java/net/NetworkInterface.java 2009-03-19 18:13:36 UTC (rev 5119) @@ -1,191 +0,0 @@ -/* NetworkInterface.java - Copyright (C) 2002 Free Software Foundation, Inc. - - This file is part of GNU Classpath. - - GNU Classpath is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - - GNU Classpath is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GNU Classpath; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. - - Linking this library statically or dynamically with other modules is - making a combined work based on this library. Thus, the terms and - conditions of the GNU General Public License cover the whole - combination. - - As a special exception, the copyright holders of this library give you - permission to link this library with independent modules to produce an - executable, regardless of the license terms of these independent - modules, and to copy and distribute the resulting executable under - terms of your choice, provided that you also meet, for each linked - independent module, the terms and conditions of the license of that - module. An independent module is a module which is not derived from - or based on this library. If you modify this library, you may extend - this exception to your version of the library, but you are not - obligated to do so. If you do not wish to do so, delete this - exception statement from your version. */ - -package java.net; - -import java.util.Enumeration; -import java.util.Iterator; -impor... [truncated message content] |