gcc/libjava/gnu/java/nio/SocketChannelImpl.java

357 lines
8.8 KiB
Java
Raw Normal View History

/* SocketChannelImpl.java --
Copyright (C) 2002, 2003, 2004, 2006 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
2005-06-30 05:22:09 +02:00
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 gnu.java.nio;
URLStreamHandler.java (toExternalForm): Removed unused variables. 2004-05-03 Tom Tromey <tromey@redhat.com> * java/net/URLStreamHandler.java (toExternalForm): Removed unused variables. unused constructor. * java/math/BigDecimal.java (divide): Removed unused variable. * java/lang/Throwable.java: Cleaned up imports. * java/lang/ClassLoader.java: Cleaned up imports. * java/io/FilePermission.java (implies): Removed unused variable. * java/awt/TextComponent.java: Removed unused import. * gnu/java/util/prefs/NodeReader.java: Cleaned up imports. * gnu/java/util/DoubleEnumeration.java: Removed unused import. * gnu/java/text/WordBreakIterator.java: Removed unused import. * gnu/java/text/SentenceBreakIterator.java: Removed unused import. * gnu/java/text/LineBreakIterator.java: Removed unused import. * gnu/java/text/CharacterBreakIterator.java: Removed unused import. * gnu/java/security/provider/DSAKeyPairGenerator.java: Cleaned up imports. * gnu/java/security/der/DERWriter.java: Cleaned up imports. * gnu/java/nio/charset/UTF_16Decoder.java (put): Removed unused method. * gnu/java/nio/SocketChannelImpl.java: Cleaned up imports. * gnu/java/nio/FileLockImpl.java: Cleaned up imports. * gnu/java/io/Base64InputStream.java: Cleaned up imports. * gnu/java/beans/info/ComponentBeanInfo.java: Cleaned up imports. * gnu/classpath/ServiceFactory.java: Cleaned up imports. (lookupProviders): Removed unused variable. (loadNextServiceProvider): Likewise. * gnu/java/beans/BeanInfoEmbryo.java: Cleaned up imports. From-SVN: r81450
2004-05-03 21:52:29 +02:00
import gnu.java.net.PlainSocketImpl;
import java.io.IOException;
URLStreamHandler.java (toExternalForm): Removed unused variables. 2004-05-03 Tom Tromey <tromey@redhat.com> * java/net/URLStreamHandler.java (toExternalForm): Removed unused variables. unused constructor. * java/math/BigDecimal.java (divide): Removed unused variable. * java/lang/Throwable.java: Cleaned up imports. * java/lang/ClassLoader.java: Cleaned up imports. * java/io/FilePermission.java (implies): Removed unused variable. * java/awt/TextComponent.java: Removed unused import. * gnu/java/util/prefs/NodeReader.java: Cleaned up imports. * gnu/java/util/DoubleEnumeration.java: Removed unused import. * gnu/java/text/WordBreakIterator.java: Removed unused import. * gnu/java/text/SentenceBreakIterator.java: Removed unused import. * gnu/java/text/LineBreakIterator.java: Removed unused import. * gnu/java/text/CharacterBreakIterator.java: Removed unused import. * gnu/java/security/provider/DSAKeyPairGenerator.java: Cleaned up imports. * gnu/java/security/der/DERWriter.java: Cleaned up imports. * gnu/java/nio/charset/UTF_16Decoder.java (put): Removed unused method. * gnu/java/nio/SocketChannelImpl.java: Cleaned up imports. * gnu/java/nio/FileLockImpl.java: Cleaned up imports. * gnu/java/io/Base64InputStream.java: Cleaned up imports. * gnu/java/beans/info/ComponentBeanInfo.java: Cleaned up imports. * gnu/classpath/ServiceFactory.java: Cleaned up imports. (lookupProviders): Removed unused variable. (loadNextServiceProvider): Likewise. * gnu/java/beans/BeanInfoEmbryo.java: Cleaned up imports. From-SVN: r81450
2004-05-03 21:52:29 +02:00
import java.io.InputStream;
2003-09-25 Michael Koch <konqueror@gmx.de> * gnu/java/nio/DatagramChannelImpl.java (DatagramChannelImpl): Made class final. (blocking): Made private. (socket): Made it a NIODatagramSocket and private. (DatagramChannelImpl): create NIODatagramSocket instead of DatagramSocket. (implConfigureBlocking): Set socket timeout. (connect): Check that channel is not closed. (write): Implemented. (write): Rewritten. (read): Implemented. (read): Rewritten. (receive): Implemented. (send): Implemented. * gnu/java/nio/SelectionKeyImpl.java (readyOps): Made private. (interestOps): Made private. (impl): Made private. (ch): Made private. (readyOps): Check if selection key is valid. (interestOps): Likewise. * gnu/java/nio/SelectorImpl.java (closed): Removed. (keys): Made private. (selected): Made private. (finalize): New method. (implCloseSelector): Rewritten. (keys): Return unmodifiable Set. (deregisterCancelledKeys): Fixed typo in method name. * gnu/java/nio/SocketChannelImpl.java (SocketChannelImpl): Made class final. (socket): Made it a NIOSocket and private. (blocking): Made private. (connected): Made private. (connectionPending): New member variable. (SocketChannelImpl): New implementation. (finalizer): Use isConnected(). (connect): Rewritten. (finishConnect): Throws IOException, implemented. (isConnectionPending): Return connectionPending. (read): Rewritten. (write): Rewritten. * gnu/java/nio/NIOConstants.java: New file. * Makefile.am (ordinary_java_source_files): Added gnu/java/nio/NIOConstants.java. * Makefile.in: Regenerated. From-SVN: r71769
2003-09-25 12:17:00 +02:00
import java.io.OutputStream;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.net.SocketAddress;
2003-09-25 Michael Koch <konqueror@gmx.de> * gnu/java/nio/DatagramChannelImpl.java (DatagramChannelImpl): Made class final. (blocking): Made private. (socket): Made it a NIODatagramSocket and private. (DatagramChannelImpl): create NIODatagramSocket instead of DatagramSocket. (implConfigureBlocking): Set socket timeout. (connect): Check that channel is not closed. (write): Implemented. (write): Rewritten. (read): Implemented. (read): Rewritten. (receive): Implemented. (send): Implemented. * gnu/java/nio/SelectionKeyImpl.java (readyOps): Made private. (interestOps): Made private. (impl): Made private. (ch): Made private. (readyOps): Check if selection key is valid. (interestOps): Likewise. * gnu/java/nio/SelectorImpl.java (closed): Removed. (keys): Made private. (selected): Made private. (finalize): New method. (implCloseSelector): Rewritten. (keys): Return unmodifiable Set. (deregisterCancelledKeys): Fixed typo in method name. * gnu/java/nio/SocketChannelImpl.java (SocketChannelImpl): Made class final. (socket): Made it a NIOSocket and private. (blocking): Made private. (connected): Made private. (connectionPending): New member variable. (SocketChannelImpl): New implementation. (finalizer): Use isConnected(). (connect): Rewritten. (finishConnect): Throws IOException, implemented. (isConnectionPending): Return connectionPending. (read): Rewritten. (write): Rewritten. * gnu/java/nio/NIOConstants.java: New file. * Makefile.am (ordinary_java_source_files): Added gnu/java/nio/NIOConstants.java. * Makefile.in: Regenerated. From-SVN: r71769
2003-09-25 12:17:00 +02:00
import java.net.SocketTimeoutException;
import java.nio.ByteBuffer;
import java.nio.channels.AlreadyConnectedException;
2003-09-25 Michael Koch <konqueror@gmx.de> * gnu/java/nio/DatagramChannelImpl.java (DatagramChannelImpl): Made class final. (blocking): Made private. (socket): Made it a NIODatagramSocket and private. (DatagramChannelImpl): create NIODatagramSocket instead of DatagramSocket. (implConfigureBlocking): Set socket timeout. (connect): Check that channel is not closed. (write): Implemented. (write): Rewritten. (read): Implemented. (read): Rewritten. (receive): Implemented. (send): Implemented. * gnu/java/nio/SelectionKeyImpl.java (readyOps): Made private. (interestOps): Made private. (impl): Made private. (ch): Made private. (readyOps): Check if selection key is valid. (interestOps): Likewise. * gnu/java/nio/SelectorImpl.java (closed): Removed. (keys): Made private. (selected): Made private. (finalize): New method. (implCloseSelector): Rewritten. (keys): Return unmodifiable Set. (deregisterCancelledKeys): Fixed typo in method name. * gnu/java/nio/SocketChannelImpl.java (SocketChannelImpl): Made class final. (socket): Made it a NIOSocket and private. (blocking): Made private. (connected): Made private. (connectionPending): New member variable. (SocketChannelImpl): New implementation. (finalizer): Use isConnected(). (connect): Rewritten. (finishConnect): Throws IOException, implemented. (isConnectionPending): Return connectionPending. (read): Rewritten. (write): Rewritten. * gnu/java/nio/NIOConstants.java: New file. * Makefile.am (ordinary_java_source_files): Added gnu/java/nio/NIOConstants.java. * Makefile.in: Regenerated. From-SVN: r71769
2003-09-25 12:17:00 +02:00
import java.nio.channels.ClosedChannelException;
import java.nio.channels.ConnectionPendingException;
import java.nio.channels.NoConnectionPendingException;
import java.nio.channels.NotYetConnectedException;
URLStreamHandler.java (toExternalForm): Removed unused variables. 2004-05-03 Tom Tromey <tromey@redhat.com> * java/net/URLStreamHandler.java (toExternalForm): Removed unused variables. unused constructor. * java/math/BigDecimal.java (divide): Removed unused variable. * java/lang/Throwable.java: Cleaned up imports. * java/lang/ClassLoader.java: Cleaned up imports. * java/io/FilePermission.java (implies): Removed unused variable. * java/awt/TextComponent.java: Removed unused import. * gnu/java/util/prefs/NodeReader.java: Cleaned up imports. * gnu/java/util/DoubleEnumeration.java: Removed unused import. * gnu/java/text/WordBreakIterator.java: Removed unused import. * gnu/java/text/SentenceBreakIterator.java: Removed unused import. * gnu/java/text/LineBreakIterator.java: Removed unused import. * gnu/java/text/CharacterBreakIterator.java: Removed unused import. * gnu/java/security/provider/DSAKeyPairGenerator.java: Cleaned up imports. * gnu/java/security/der/DERWriter.java: Cleaned up imports. * gnu/java/nio/charset/UTF_16Decoder.java (put): Removed unused method. * gnu/java/nio/SocketChannelImpl.java: Cleaned up imports. * gnu/java/nio/FileLockImpl.java: Cleaned up imports. * gnu/java/io/Base64InputStream.java: Cleaned up imports. * gnu/java/beans/info/ComponentBeanInfo.java: Cleaned up imports. * gnu/classpath/ServiceFactory.java: Cleaned up imports. (lookupProviders): Removed unused variable. (loadNextServiceProvider): Likewise. * gnu/java/beans/BeanInfoEmbryo.java: Cleaned up imports. From-SVN: r81450
2004-05-03 21:52:29 +02:00
import java.nio.channels.SelectionKey;
import java.nio.channels.Selector;
import java.nio.channels.SocketChannel;
2003-09-25 Michael Koch <konqueror@gmx.de> * gnu/java/nio/DatagramChannelImpl.java (DatagramChannelImpl): Made class final. (blocking): Made private. (socket): Made it a NIODatagramSocket and private. (DatagramChannelImpl): create NIODatagramSocket instead of DatagramSocket. (implConfigureBlocking): Set socket timeout. (connect): Check that channel is not closed. (write): Implemented. (write): Rewritten. (read): Implemented. (read): Rewritten. (receive): Implemented. (send): Implemented. * gnu/java/nio/SelectionKeyImpl.java (readyOps): Made private. (interestOps): Made private. (impl): Made private. (ch): Made private. (readyOps): Check if selection key is valid. (interestOps): Likewise. * gnu/java/nio/SelectorImpl.java (closed): Removed. (keys): Made private. (selected): Made private. (finalize): New method. (implCloseSelector): Rewritten. (keys): Return unmodifiable Set. (deregisterCancelledKeys): Fixed typo in method name. * gnu/java/nio/SocketChannelImpl.java (SocketChannelImpl): Made class final. (socket): Made it a NIOSocket and private. (blocking): Made private. (connected): Made private. (connectionPending): New member variable. (SocketChannelImpl): New implementation. (finalizer): Use isConnected(). (connect): Rewritten. (finishConnect): Throws IOException, implemented. (isConnectionPending): Return connectionPending. (read): Rewritten. (write): Rewritten. * gnu/java/nio/NIOConstants.java: New file. * Makefile.am (ordinary_java_source_files): Added gnu/java/nio/NIOConstants.java. * Makefile.in: Regenerated. From-SVN: r71769
2003-09-25 12:17:00 +02:00
import java.nio.channels.UnresolvedAddressException;
import java.nio.channels.UnsupportedAddressTypeException;
import java.nio.channels.spi.SelectorProvider;
2003-09-25 Michael Koch <konqueror@gmx.de> * gnu/java/nio/DatagramChannelImpl.java (DatagramChannelImpl): Made class final. (blocking): Made private. (socket): Made it a NIODatagramSocket and private. (DatagramChannelImpl): create NIODatagramSocket instead of DatagramSocket. (implConfigureBlocking): Set socket timeout. (connect): Check that channel is not closed. (write): Implemented. (write): Rewritten. (read): Implemented. (read): Rewritten. (receive): Implemented. (send): Implemented. * gnu/java/nio/SelectionKeyImpl.java (readyOps): Made private. (interestOps): Made private. (impl): Made private. (ch): Made private. (readyOps): Check if selection key is valid. (interestOps): Likewise. * gnu/java/nio/SelectorImpl.java (closed): Removed. (keys): Made private. (selected): Made private. (finalize): New method. (implCloseSelector): Rewritten. (keys): Return unmodifiable Set. (deregisterCancelledKeys): Fixed typo in method name. * gnu/java/nio/SocketChannelImpl.java (SocketChannelImpl): Made class final. (socket): Made it a NIOSocket and private. (blocking): Made private. (connected): Made private. (connectionPending): New member variable. (SocketChannelImpl): New implementation. (finalizer): Use isConnected(). (connect): Rewritten. (finishConnect): Throws IOException, implemented. (isConnectionPending): Return connectionPending. (read): Rewritten. (write): Rewritten. * gnu/java/nio/NIOConstants.java: New file. * Makefile.am (ordinary_java_source_files): Added gnu/java/nio/NIOConstants.java. * Makefile.in: Regenerated. From-SVN: r71769
2003-09-25 12:17:00 +02:00
public final class SocketChannelImpl extends SocketChannel
{
private PlainSocketImpl impl;
2003-09-25 Michael Koch <konqueror@gmx.de> * gnu/java/nio/DatagramChannelImpl.java (DatagramChannelImpl): Made class final. (blocking): Made private. (socket): Made it a NIODatagramSocket and private. (DatagramChannelImpl): create NIODatagramSocket instead of DatagramSocket. (implConfigureBlocking): Set socket timeout. (connect): Check that channel is not closed. (write): Implemented. (write): Rewritten. (read): Implemented. (read): Rewritten. (receive): Implemented. (send): Implemented. * gnu/java/nio/SelectionKeyImpl.java (readyOps): Made private. (interestOps): Made private. (impl): Made private. (ch): Made private. (readyOps): Check if selection key is valid. (interestOps): Likewise. * gnu/java/nio/SelectorImpl.java (closed): Removed. (keys): Made private. (selected): Made private. (finalize): New method. (implCloseSelector): Rewritten. (keys): Return unmodifiable Set. (deregisterCancelledKeys): Fixed typo in method name. * gnu/java/nio/SocketChannelImpl.java (SocketChannelImpl): Made class final. (socket): Made it a NIOSocket and private. (blocking): Made private. (connected): Made private. (connectionPending): New member variable. (SocketChannelImpl): New implementation. (finalizer): Use isConnected(). (connect): Rewritten. (finishConnect): Throws IOException, implemented. (isConnectionPending): Return connectionPending. (read): Rewritten. (write): Rewritten. * gnu/java/nio/NIOConstants.java: New file. * Makefile.am (ordinary_java_source_files): Added gnu/java/nio/NIOConstants.java. * Makefile.in: Regenerated. From-SVN: r71769
2003-09-25 12:17:00 +02:00
private NIOSocket socket;
private boolean connectionPending;
2003-09-25 Michael Koch <konqueror@gmx.de> * gnu/java/nio/DatagramChannelImpl.java (DatagramChannelImpl): Made class final. (blocking): Made private. (socket): Made it a NIODatagramSocket and private. (DatagramChannelImpl): create NIODatagramSocket instead of DatagramSocket. (implConfigureBlocking): Set socket timeout. (connect): Check that channel is not closed. (write): Implemented. (write): Rewritten. (read): Implemented. (read): Rewritten. (receive): Implemented. (send): Implemented. * gnu/java/nio/SelectionKeyImpl.java (readyOps): Made private. (interestOps): Made private. (impl): Made private. (ch): Made private. (readyOps): Check if selection key is valid. (interestOps): Likewise. * gnu/java/nio/SelectorImpl.java (closed): Removed. (keys): Made private. (selected): Made private. (finalize): New method. (implCloseSelector): Rewritten. (keys): Return unmodifiable Set. (deregisterCancelledKeys): Fixed typo in method name. * gnu/java/nio/SocketChannelImpl.java (SocketChannelImpl): Made class final. (socket): Made it a NIOSocket and private. (blocking): Made private. (connected): Made private. (connectionPending): New member variable. (SocketChannelImpl): New implementation. (finalizer): Use isConnected(). (connect): Rewritten. (finishConnect): Throws IOException, implemented. (isConnectionPending): Return connectionPending. (read): Rewritten. (write): Rewritten. * gnu/java/nio/NIOConstants.java: New file. * Makefile.am (ordinary_java_source_files): Added gnu/java/nio/NIOConstants.java. * Makefile.in: Regenerated. From-SVN: r71769
2003-09-25 12:17:00 +02:00
SocketChannelImpl (SelectorProvider provider)
throws IOException
{
super (provider);
impl = new PlainSocketImpl();
socket = new NIOSocket (impl, this);
configureBlocking(true);
2003-09-25 Michael Koch <konqueror@gmx.de> * gnu/java/nio/DatagramChannelImpl.java (DatagramChannelImpl): Made class final. (blocking): Made private. (socket): Made it a NIODatagramSocket and private. (DatagramChannelImpl): create NIODatagramSocket instead of DatagramSocket. (implConfigureBlocking): Set socket timeout. (connect): Check that channel is not closed. (write): Implemented. (write): Rewritten. (read): Implemented. (read): Rewritten. (receive): Implemented. (send): Implemented. * gnu/java/nio/SelectionKeyImpl.java (readyOps): Made private. (interestOps): Made private. (impl): Made private. (ch): Made private. (readyOps): Check if selection key is valid. (interestOps): Likewise. * gnu/java/nio/SelectorImpl.java (closed): Removed. (keys): Made private. (selected): Made private. (finalize): New method. (implCloseSelector): Rewritten. (keys): Return unmodifiable Set. (deregisterCancelledKeys): Fixed typo in method name. * gnu/java/nio/SocketChannelImpl.java (SocketChannelImpl): Made class final. (socket): Made it a NIOSocket and private. (blocking): Made private. (connected): Made private. (connectionPending): New member variable. (SocketChannelImpl): New implementation. (finalizer): Use isConnected(). (connect): Rewritten. (finishConnect): Throws IOException, implemented. (isConnectionPending): Return connectionPending. (read): Rewritten. (write): Rewritten. * gnu/java/nio/NIOConstants.java: New file. * Makefile.am (ordinary_java_source_files): Added gnu/java/nio/NIOConstants.java. * Makefile.in: Regenerated. From-SVN: r71769
2003-09-25 12:17:00 +02:00
}
SocketChannelImpl (SelectorProvider provider,
NIOSocket socket)
throws IOException
{
super (provider);
this.impl = socket.getPlainSocketImpl();
2003-09-25 Michael Koch <konqueror@gmx.de> * gnu/java/nio/DatagramChannelImpl.java (DatagramChannelImpl): Made class final. (blocking): Made private. (socket): Made it a NIODatagramSocket and private. (DatagramChannelImpl): create NIODatagramSocket instead of DatagramSocket. (implConfigureBlocking): Set socket timeout. (connect): Check that channel is not closed. (write): Implemented. (write): Rewritten. (read): Implemented. (read): Rewritten. (receive): Implemented. (send): Implemented. * gnu/java/nio/SelectionKeyImpl.java (readyOps): Made private. (interestOps): Made private. (impl): Made private. (ch): Made private. (readyOps): Check if selection key is valid. (interestOps): Likewise. * gnu/java/nio/SelectorImpl.java (closed): Removed. (keys): Made private. (selected): Made private. (finalize): New method. (implCloseSelector): Rewritten. (keys): Return unmodifiable Set. (deregisterCancelledKeys): Fixed typo in method name. * gnu/java/nio/SocketChannelImpl.java (SocketChannelImpl): Made class final. (socket): Made it a NIOSocket and private. (blocking): Made private. (connected): Made private. (connectionPending): New member variable. (SocketChannelImpl): New implementation. (finalizer): Use isConnected(). (connect): Rewritten. (finishConnect): Throws IOException, implemented. (isConnectionPending): Return connectionPending. (read): Rewritten. (write): Rewritten. * gnu/java/nio/NIOConstants.java: New file. * Makefile.am (ordinary_java_source_files): Added gnu/java/nio/NIOConstants.java. * Makefile.in: Regenerated. From-SVN: r71769
2003-09-25 12:17:00 +02:00
this.socket = socket;
}
public void finalizer()
{
2003-09-25 Michael Koch <konqueror@gmx.de> * gnu/java/nio/DatagramChannelImpl.java (DatagramChannelImpl): Made class final. (blocking): Made private. (socket): Made it a NIODatagramSocket and private. (DatagramChannelImpl): create NIODatagramSocket instead of DatagramSocket. (implConfigureBlocking): Set socket timeout. (connect): Check that channel is not closed. (write): Implemented. (write): Rewritten. (read): Implemented. (read): Rewritten. (receive): Implemented. (send): Implemented. * gnu/java/nio/SelectionKeyImpl.java (readyOps): Made private. (interestOps): Made private. (impl): Made private. (ch): Made private. (readyOps): Check if selection key is valid. (interestOps): Likewise. * gnu/java/nio/SelectorImpl.java (closed): Removed. (keys): Made private. (selected): Made private. (finalize): New method. (implCloseSelector): Rewritten. (keys): Return unmodifiable Set. (deregisterCancelledKeys): Fixed typo in method name. * gnu/java/nio/SocketChannelImpl.java (SocketChannelImpl): Made class final. (socket): Made it a NIOSocket and private. (blocking): Made private. (connected): Made private. (connectionPending): New member variable. (SocketChannelImpl): New implementation. (finalizer): Use isConnected(). (connect): Rewritten. (finishConnect): Throws IOException, implemented. (isConnectionPending): Return connectionPending. (read): Rewritten. (write): Rewritten. * gnu/java/nio/NIOConstants.java: New file. * Makefile.am (ordinary_java_source_files): Added gnu/java/nio/NIOConstants.java. * Makefile.in: Regenerated. From-SVN: r71769
2003-09-25 12:17:00 +02:00
if (isConnected())
{
try
{
close ();
}
catch (Exception e)
{
}
}
}
PlainSocketImpl getPlainSocketImpl()
{
return impl;
}
int getNativeFD()
{
return socket.getPlainSocketImpl().getNativeFD();
}
protected void implCloseSelectableChannel () throws IOException
{
socket.close();
}
protected void implConfigureBlocking (boolean blocking) throws IOException
{
2003-09-25 Michael Koch <konqueror@gmx.de> * gnu/java/nio/DatagramChannelImpl.java (DatagramChannelImpl): Made class final. (blocking): Made private. (socket): Made it a NIODatagramSocket and private. (DatagramChannelImpl): create NIODatagramSocket instead of DatagramSocket. (implConfigureBlocking): Set socket timeout. (connect): Check that channel is not closed. (write): Implemented. (write): Rewritten. (read): Implemented. (read): Rewritten. (receive): Implemented. (send): Implemented. * gnu/java/nio/SelectionKeyImpl.java (readyOps): Made private. (interestOps): Made private. (impl): Made private. (ch): Made private. (readyOps): Check if selection key is valid. (interestOps): Likewise. * gnu/java/nio/SelectorImpl.java (closed): Removed. (keys): Made private. (selected): Made private. (finalize): New method. (implCloseSelector): Rewritten. (keys): Return unmodifiable Set. (deregisterCancelledKeys): Fixed typo in method name. * gnu/java/nio/SocketChannelImpl.java (SocketChannelImpl): Made class final. (socket): Made it a NIOSocket and private. (blocking): Made private. (connected): Made private. (connectionPending): New member variable. (SocketChannelImpl): New implementation. (finalizer): Use isConnected(). (connect): Rewritten. (finishConnect): Throws IOException, implemented. (isConnectionPending): Return connectionPending. (read): Rewritten. (write): Rewritten. * gnu/java/nio/NIOConstants.java: New file. * Makefile.am (ordinary_java_source_files): Added gnu/java/nio/NIOConstants.java. * Makefile.in: Regenerated. From-SVN: r71769
2003-09-25 12:17:00 +02:00
socket.setSoTimeout (blocking ? 0 : NIOConstants.DEFAULT_TIMEOUT);
}
public boolean connect (SocketAddress remote) throws IOException
{
2003-09-25 Michael Koch <konqueror@gmx.de> * gnu/java/nio/DatagramChannelImpl.java (DatagramChannelImpl): Made class final. (blocking): Made private. (socket): Made it a NIODatagramSocket and private. (DatagramChannelImpl): create NIODatagramSocket instead of DatagramSocket. (implConfigureBlocking): Set socket timeout. (connect): Check that channel is not closed. (write): Implemented. (write): Rewritten. (read): Implemented. (read): Rewritten. (receive): Implemented. (send): Implemented. * gnu/java/nio/SelectionKeyImpl.java (readyOps): Made private. (interestOps): Made private. (impl): Made private. (ch): Made private. (readyOps): Check if selection key is valid. (interestOps): Likewise. * gnu/java/nio/SelectorImpl.java (closed): Removed. (keys): Made private. (selected): Made private. (finalize): New method. (implCloseSelector): Rewritten. (keys): Return unmodifiable Set. (deregisterCancelledKeys): Fixed typo in method name. * gnu/java/nio/SocketChannelImpl.java (SocketChannelImpl): Made class final. (socket): Made it a NIOSocket and private. (blocking): Made private. (connected): Made private. (connectionPending): New member variable. (SocketChannelImpl): New implementation. (finalizer): Use isConnected(). (connect): Rewritten. (finishConnect): Throws IOException, implemented. (isConnectionPending): Return connectionPending. (read): Rewritten. (write): Rewritten. * gnu/java/nio/NIOConstants.java: New file. * Makefile.am (ordinary_java_source_files): Added gnu/java/nio/NIOConstants.java. * Makefile.in: Regenerated. From-SVN: r71769
2003-09-25 12:17:00 +02:00
if (!isOpen())
throw new ClosedChannelException();
if (isConnected())
throw new AlreadyConnectedException();
2003-09-25 Michael Koch <konqueror@gmx.de> * gnu/java/nio/DatagramChannelImpl.java (DatagramChannelImpl): Made class final. (blocking): Made private. (socket): Made it a NIODatagramSocket and private. (DatagramChannelImpl): create NIODatagramSocket instead of DatagramSocket. (implConfigureBlocking): Set socket timeout. (connect): Check that channel is not closed. (write): Implemented. (write): Rewritten. (read): Implemented. (read): Rewritten. (receive): Implemented. (send): Implemented. * gnu/java/nio/SelectionKeyImpl.java (readyOps): Made private. (interestOps): Made private. (impl): Made private. (ch): Made private. (readyOps): Check if selection key is valid. (interestOps): Likewise. * gnu/java/nio/SelectorImpl.java (closed): Removed. (keys): Made private. (selected): Made private. (finalize): New method. (implCloseSelector): Rewritten. (keys): Return unmodifiable Set. (deregisterCancelledKeys): Fixed typo in method name. * gnu/java/nio/SocketChannelImpl.java (SocketChannelImpl): Made class final. (socket): Made it a NIOSocket and private. (blocking): Made private. (connected): Made private. (connectionPending): New member variable. (SocketChannelImpl): New implementation. (finalizer): Use isConnected(). (connect): Rewritten. (finishConnect): Throws IOException, implemented. (isConnectionPending): Return connectionPending. (read): Rewritten. (write): Rewritten. * gnu/java/nio/NIOConstants.java: New file. * Makefile.am (ordinary_java_source_files): Added gnu/java/nio/NIOConstants.java. * Makefile.in: Regenerated. From-SVN: r71769
2003-09-25 12:17:00 +02:00
if (connectionPending)
throw new ConnectionPendingException();
if (!(remote instanceof InetSocketAddress))
throw new UnsupportedAddressTypeException();
if (((InetSocketAddress) remote).isUnresolved())
throw new UnresolvedAddressException();
try
{
socket.getPlainSocketImpl().setInChannelOperation(true);
// indicate that a channel is initiating the accept operation
// so that the socket ignores the fact that we might be in
// non-blocking mode.
if (isBlocking())
{
// Do blocking connect.
socket.connect (remote);
return true;
}
// Do non-blocking connect.
try
{
socket.connect (remote, NIOConstants.DEFAULT_TIMEOUT);
return true;
}
catch (SocketTimeoutException e)
{
connectionPending = true;
return false;
}
2003-09-25 Michael Koch <konqueror@gmx.de> * gnu/java/nio/DatagramChannelImpl.java (DatagramChannelImpl): Made class final. (blocking): Made private. (socket): Made it a NIODatagramSocket and private. (DatagramChannelImpl): create NIODatagramSocket instead of DatagramSocket. (implConfigureBlocking): Set socket timeout. (connect): Check that channel is not closed. (write): Implemented. (write): Rewritten. (read): Implemented. (read): Rewritten. (receive): Implemented. (send): Implemented. * gnu/java/nio/SelectionKeyImpl.java (readyOps): Made private. (interestOps): Made private. (impl): Made private. (ch): Made private. (readyOps): Check if selection key is valid. (interestOps): Likewise. * gnu/java/nio/SelectorImpl.java (closed): Removed. (keys): Made private. (selected): Made private. (finalize): New method. (implCloseSelector): Rewritten. (keys): Return unmodifiable Set. (deregisterCancelledKeys): Fixed typo in method name. * gnu/java/nio/SocketChannelImpl.java (SocketChannelImpl): Made class final. (socket): Made it a NIOSocket and private. (blocking): Made private. (connected): Made private. (connectionPending): New member variable. (SocketChannelImpl): New implementation. (finalizer): Use isConnected(). (connect): Rewritten. (finishConnect): Throws IOException, implemented. (isConnectionPending): Return connectionPending. (read): Rewritten. (write): Rewritten. * gnu/java/nio/NIOConstants.java: New file. * Makefile.am (ordinary_java_source_files): Added gnu/java/nio/NIOConstants.java. * Makefile.in: Regenerated. From-SVN: r71769
2003-09-25 12:17:00 +02:00
}
finally
2003-09-25 Michael Koch <konqueror@gmx.de> * gnu/java/nio/DatagramChannelImpl.java (DatagramChannelImpl): Made class final. (blocking): Made private. (socket): Made it a NIODatagramSocket and private. (DatagramChannelImpl): create NIODatagramSocket instead of DatagramSocket. (implConfigureBlocking): Set socket timeout. (connect): Check that channel is not closed. (write): Implemented. (write): Rewritten. (read): Implemented. (read): Rewritten. (receive): Implemented. (send): Implemented. * gnu/java/nio/SelectionKeyImpl.java (readyOps): Made private. (interestOps): Made private. (impl): Made private. (ch): Made private. (readyOps): Check if selection key is valid. (interestOps): Likewise. * gnu/java/nio/SelectorImpl.java (closed): Removed. (keys): Made private. (selected): Made private. (finalize): New method. (implCloseSelector): Rewritten. (keys): Return unmodifiable Set. (deregisterCancelledKeys): Fixed typo in method name. * gnu/java/nio/SocketChannelImpl.java (SocketChannelImpl): Made class final. (socket): Made it a NIOSocket and private. (blocking): Made private. (connected): Made private. (connectionPending): New member variable. (SocketChannelImpl): New implementation. (finalizer): Use isConnected(). (connect): Rewritten. (finishConnect): Throws IOException, implemented. (isConnectionPending): Return connectionPending. (read): Rewritten. (write): Rewritten. * gnu/java/nio/NIOConstants.java: New file. * Makefile.am (ordinary_java_source_files): Added gnu/java/nio/NIOConstants.java. * Makefile.in: Regenerated. From-SVN: r71769
2003-09-25 12:17:00 +02:00
{
socket.getPlainSocketImpl().setInChannelOperation(false);
2003-09-25 Michael Koch <konqueror@gmx.de> * gnu/java/nio/DatagramChannelImpl.java (DatagramChannelImpl): Made class final. (blocking): Made private. (socket): Made it a NIODatagramSocket and private. (DatagramChannelImpl): create NIODatagramSocket instead of DatagramSocket. (implConfigureBlocking): Set socket timeout. (connect): Check that channel is not closed. (write): Implemented. (write): Rewritten. (read): Implemented. (read): Rewritten. (receive): Implemented. (send): Implemented. * gnu/java/nio/SelectionKeyImpl.java (readyOps): Made private. (interestOps): Made private. (impl): Made private. (ch): Made private. (readyOps): Check if selection key is valid. (interestOps): Likewise. * gnu/java/nio/SelectorImpl.java (closed): Removed. (keys): Made private. (selected): Made private. (finalize): New method. (implCloseSelector): Rewritten. (keys): Return unmodifiable Set. (deregisterCancelledKeys): Fixed typo in method name. * gnu/java/nio/SocketChannelImpl.java (SocketChannelImpl): Made class final. (socket): Made it a NIOSocket and private. (blocking): Made private. (connected): Made private. (connectionPending): New member variable. (SocketChannelImpl): New implementation. (finalizer): Use isConnected(). (connect): Rewritten. (finishConnect): Throws IOException, implemented. (isConnectionPending): Return connectionPending. (read): Rewritten. (write): Rewritten. * gnu/java/nio/NIOConstants.java: New file. * Makefile.am (ordinary_java_source_files): Added gnu/java/nio/NIOConstants.java. * Makefile.in: Regenerated. From-SVN: r71769
2003-09-25 12:17:00 +02:00
}
}
public boolean finishConnect ()
2003-09-25 Michael Koch <konqueror@gmx.de> * gnu/java/nio/DatagramChannelImpl.java (DatagramChannelImpl): Made class final. (blocking): Made private. (socket): Made it a NIODatagramSocket and private. (DatagramChannelImpl): create NIODatagramSocket instead of DatagramSocket. (implConfigureBlocking): Set socket timeout. (connect): Check that channel is not closed. (write): Implemented. (write): Rewritten. (read): Implemented. (read): Rewritten. (receive): Implemented. (send): Implemented. * gnu/java/nio/SelectionKeyImpl.java (readyOps): Made private. (interestOps): Made private. (impl): Made private. (ch): Made private. (readyOps): Check if selection key is valid. (interestOps): Likewise. * gnu/java/nio/SelectorImpl.java (closed): Removed. (keys): Made private. (selected): Made private. (finalize): New method. (implCloseSelector): Rewritten. (keys): Return unmodifiable Set. (deregisterCancelledKeys): Fixed typo in method name. * gnu/java/nio/SocketChannelImpl.java (SocketChannelImpl): Made class final. (socket): Made it a NIOSocket and private. (blocking): Made private. (connected): Made private. (connectionPending): New member variable. (SocketChannelImpl): New implementation. (finalizer): Use isConnected(). (connect): Rewritten. (finishConnect): Throws IOException, implemented. (isConnectionPending): Return connectionPending. (read): Rewritten. (write): Rewritten. * gnu/java/nio/NIOConstants.java: New file. * Makefile.am (ordinary_java_source_files): Added gnu/java/nio/NIOConstants.java. * Makefile.in: Regenerated. From-SVN: r71769
2003-09-25 12:17:00 +02:00
throws IOException
{
2003-09-25 Michael Koch <konqueror@gmx.de> * gnu/java/nio/DatagramChannelImpl.java (DatagramChannelImpl): Made class final. (blocking): Made private. (socket): Made it a NIODatagramSocket and private. (DatagramChannelImpl): create NIODatagramSocket instead of DatagramSocket. (implConfigureBlocking): Set socket timeout. (connect): Check that channel is not closed. (write): Implemented. (write): Rewritten. (read): Implemented. (read): Rewritten. (receive): Implemented. (send): Implemented. * gnu/java/nio/SelectionKeyImpl.java (readyOps): Made private. (interestOps): Made private. (impl): Made private. (ch): Made private. (readyOps): Check if selection key is valid. (interestOps): Likewise. * gnu/java/nio/SelectorImpl.java (closed): Removed. (keys): Made private. (selected): Made private. (finalize): New method. (implCloseSelector): Rewritten. (keys): Return unmodifiable Set. (deregisterCancelledKeys): Fixed typo in method name. * gnu/java/nio/SocketChannelImpl.java (SocketChannelImpl): Made class final. (socket): Made it a NIOSocket and private. (blocking): Made private. (connected): Made private. (connectionPending): New member variable. (SocketChannelImpl): New implementation. (finalizer): Use isConnected(). (connect): Rewritten. (finishConnect): Throws IOException, implemented. (isConnectionPending): Return connectionPending. (read): Rewritten. (write): Rewritten. * gnu/java/nio/NIOConstants.java: New file. * Makefile.am (ordinary_java_source_files): Added gnu/java/nio/NIOConstants.java. * Makefile.in: Regenerated. From-SVN: r71769
2003-09-25 12:17:00 +02:00
if (!isOpen())
throw new ClosedChannelException();
if (!isConnected() && !connectionPending)
2003-09-25 Michael Koch <konqueror@gmx.de> * gnu/java/nio/DatagramChannelImpl.java (DatagramChannelImpl): Made class final. (blocking): Made private. (socket): Made it a NIODatagramSocket and private. (DatagramChannelImpl): create NIODatagramSocket instead of DatagramSocket. (implConfigureBlocking): Set socket timeout. (connect): Check that channel is not closed. (write): Implemented. (write): Rewritten. (read): Implemented. (read): Rewritten. (receive): Implemented. (send): Implemented. * gnu/java/nio/SelectionKeyImpl.java (readyOps): Made private. (interestOps): Made private. (impl): Made private. (ch): Made private. (readyOps): Check if selection key is valid. (interestOps): Likewise. * gnu/java/nio/SelectorImpl.java (closed): Removed. (keys): Made private. (selected): Made private. (finalize): New method. (implCloseSelector): Rewritten. (keys): Return unmodifiable Set. (deregisterCancelledKeys): Fixed typo in method name. * gnu/java/nio/SocketChannelImpl.java (SocketChannelImpl): Made class final. (socket): Made it a NIOSocket and private. (blocking): Made private. (connected): Made private. (connectionPending): New member variable. (SocketChannelImpl): New implementation. (finalizer): Use isConnected(). (connect): Rewritten. (finishConnect): Throws IOException, implemented. (isConnectionPending): Return connectionPending. (read): Rewritten. (write): Rewritten. * gnu/java/nio/NIOConstants.java: New file. * Makefile.am (ordinary_java_source_files): Added gnu/java/nio/NIOConstants.java. * Makefile.in: Regenerated. From-SVN: r71769
2003-09-25 12:17:00 +02:00
throw new NoConnectionPendingException();
if (isConnected())
return true;
// FIXME: Handle blocking/non-blocking mode.
Selector selector = provider().openSelector();
register(selector, SelectionKey.OP_CONNECT);
2003-09-25 Michael Koch <konqueror@gmx.de> * gnu/java/nio/DatagramChannelImpl.java (DatagramChannelImpl): Made class final. (blocking): Made private. (socket): Made it a NIODatagramSocket and private. (DatagramChannelImpl): create NIODatagramSocket instead of DatagramSocket. (implConfigureBlocking): Set socket timeout. (connect): Check that channel is not closed. (write): Implemented. (write): Rewritten. (read): Implemented. (read): Rewritten. (receive): Implemented. (send): Implemented. * gnu/java/nio/SelectionKeyImpl.java (readyOps): Made private. (interestOps): Made private. (impl): Made private. (ch): Made private. (readyOps): Check if selection key is valid. (interestOps): Likewise. * gnu/java/nio/SelectorImpl.java (closed): Removed. (keys): Made private. (selected): Made private. (finalize): New method. (implCloseSelector): Rewritten. (keys): Return unmodifiable Set. (deregisterCancelledKeys): Fixed typo in method name. * gnu/java/nio/SocketChannelImpl.java (SocketChannelImpl): Made class final. (socket): Made it a NIOSocket and private. (blocking): Made private. (connected): Made private. (connectionPending): New member variable. (SocketChannelImpl): New implementation. (finalizer): Use isConnected(). (connect): Rewritten. (finishConnect): Throws IOException, implemented. (isConnectionPending): Return connectionPending. (read): Rewritten. (write): Rewritten. * gnu/java/nio/NIOConstants.java: New file. * Makefile.am (ordinary_java_source_files): Added gnu/java/nio/NIOConstants.java. * Makefile.in: Regenerated. From-SVN: r71769
2003-09-25 12:17:00 +02:00
if (isBlocking())
{
selector.select(); // blocking until channel is connected.
connectionPending = false;
return true;
}
int ready = selector.selectNow(); // non-blocking
if (ready == 1)
{
connectionPending = false;
return true;
}
return false;
}
public boolean isConnected ()
{
return socket.isConnected();
}
public boolean isConnectionPending ()
{
2003-09-25 Michael Koch <konqueror@gmx.de> * gnu/java/nio/DatagramChannelImpl.java (DatagramChannelImpl): Made class final. (blocking): Made private. (socket): Made it a NIODatagramSocket and private. (DatagramChannelImpl): create NIODatagramSocket instead of DatagramSocket. (implConfigureBlocking): Set socket timeout. (connect): Check that channel is not closed. (write): Implemented. (write): Rewritten. (read): Implemented. (read): Rewritten. (receive): Implemented. (send): Implemented. * gnu/java/nio/SelectionKeyImpl.java (readyOps): Made private. (interestOps): Made private. (impl): Made private. (ch): Made private. (readyOps): Check if selection key is valid. (interestOps): Likewise. * gnu/java/nio/SelectorImpl.java (closed): Removed. (keys): Made private. (selected): Made private. (finalize): New method. (implCloseSelector): Rewritten. (keys): Return unmodifiable Set. (deregisterCancelledKeys): Fixed typo in method name. * gnu/java/nio/SocketChannelImpl.java (SocketChannelImpl): Made class final. (socket): Made it a NIOSocket and private. (blocking): Made private. (connected): Made private. (connectionPending): New member variable. (SocketChannelImpl): New implementation. (finalizer): Use isConnected(). (connect): Rewritten. (finishConnect): Throws IOException, implemented. (isConnectionPending): Return connectionPending. (read): Rewritten. (write): Rewritten. * gnu/java/nio/NIOConstants.java: New file. * Makefile.am (ordinary_java_source_files): Added gnu/java/nio/NIOConstants.java. * Makefile.in: Regenerated. From-SVN: r71769
2003-09-25 12:17:00 +02:00
return connectionPending;
}
public Socket socket ()
{
return socket;
}
public int read(ByteBuffer dst) throws IOException
{
if (!isConnected())
2003-09-25 Michael Koch <konqueror@gmx.de> * gnu/java/nio/DatagramChannelImpl.java (DatagramChannelImpl): Made class final. (blocking): Made private. (socket): Made it a NIODatagramSocket and private. (DatagramChannelImpl): create NIODatagramSocket instead of DatagramSocket. (implConfigureBlocking): Set socket timeout. (connect): Check that channel is not closed. (write): Implemented. (write): Rewritten. (read): Implemented. (read): Rewritten. (receive): Implemented. (send): Implemented. * gnu/java/nio/SelectionKeyImpl.java (readyOps): Made private. (interestOps): Made private. (impl): Made private. (ch): Made private. (readyOps): Check if selection key is valid. (interestOps): Likewise. * gnu/java/nio/SelectorImpl.java (closed): Removed. (keys): Made private. (selected): Made private. (finalize): New method. (implCloseSelector): Rewritten. (keys): Return unmodifiable Set. (deregisterCancelledKeys): Fixed typo in method name. * gnu/java/nio/SocketChannelImpl.java (SocketChannelImpl): Made class final. (socket): Made it a NIOSocket and private. (blocking): Made private. (connected): Made private. (connectionPending): New member variable. (SocketChannelImpl): New implementation. (finalizer): Use isConnected(). (connect): Rewritten. (finishConnect): Throws IOException, implemented. (isConnectionPending): Return connectionPending. (read): Rewritten. (write): Rewritten. * gnu/java/nio/NIOConstants.java: New file. * Makefile.am (ordinary_java_source_files): Added gnu/java/nio/NIOConstants.java. * Makefile.in: Regenerated. From-SVN: r71769
2003-09-25 12:17:00 +02:00
throw new NotYetConnectedException();
byte[] data;
2003-09-25 Michael Koch <konqueror@gmx.de> * gnu/java/nio/DatagramChannelImpl.java (DatagramChannelImpl): Made class final. (blocking): Made private. (socket): Made it a NIODatagramSocket and private. (DatagramChannelImpl): create NIODatagramSocket instead of DatagramSocket. (implConfigureBlocking): Set socket timeout. (connect): Check that channel is not closed. (write): Implemented. (write): Rewritten. (read): Implemented. (read): Rewritten. (receive): Implemented. (send): Implemented. * gnu/java/nio/SelectionKeyImpl.java (readyOps): Made private. (interestOps): Made private. (impl): Made private. (ch): Made private. (readyOps): Check if selection key is valid. (interestOps): Likewise. * gnu/java/nio/SelectorImpl.java (closed): Removed. (keys): Made private. (selected): Made private. (finalize): New method. (implCloseSelector): Rewritten. (keys): Return unmodifiable Set. (deregisterCancelledKeys): Fixed typo in method name. * gnu/java/nio/SocketChannelImpl.java (SocketChannelImpl): Made class final. (socket): Made it a NIOSocket and private. (blocking): Made private. (connected): Made private. (connectionPending): New member variable. (SocketChannelImpl): New implementation. (finalizer): Use isConnected(). (connect): Rewritten. (finishConnect): Throws IOException, implemented. (isConnectionPending): Return connectionPending. (read): Rewritten. (write): Rewritten. * gnu/java/nio/NIOConstants.java: New file. * Makefile.am (ordinary_java_source_files): Added gnu/java/nio/NIOConstants.java. * Makefile.in: Regenerated. From-SVN: r71769
2003-09-25 12:17:00 +02:00
int offset = 0;
InputStream input = socket.getInputStream();
int available = input.available();
int len = dst.remaining();
if ((! isBlocking()) && available == 0)
return 0;
2003-09-25 Michael Koch <konqueror@gmx.de> * gnu/java/nio/DatagramChannelImpl.java (DatagramChannelImpl): Made class final. (blocking): Made private. (socket): Made it a NIODatagramSocket and private. (DatagramChannelImpl): create NIODatagramSocket instead of DatagramSocket. (implConfigureBlocking): Set socket timeout. (connect): Check that channel is not closed. (write): Implemented. (write): Rewritten. (read): Implemented. (read): Rewritten. (receive): Implemented. (send): Implemented. * gnu/java/nio/SelectionKeyImpl.java (readyOps): Made private. (interestOps): Made private. (impl): Made private. (ch): Made private. (readyOps): Check if selection key is valid. (interestOps): Likewise. * gnu/java/nio/SelectorImpl.java (closed): Removed. (keys): Made private. (selected): Made private. (finalize): New method. (implCloseSelector): Rewritten. (keys): Return unmodifiable Set. (deregisterCancelledKeys): Fixed typo in method name. * gnu/java/nio/SocketChannelImpl.java (SocketChannelImpl): Made class final. (socket): Made it a NIOSocket and private. (blocking): Made private. (connected): Made private. (connectionPending): New member variable. (SocketChannelImpl): New implementation. (finalizer): Use isConnected(). (connect): Rewritten. (finishConnect): Throws IOException, implemented. (isConnectionPending): Return connectionPending. (read): Rewritten. (write): Rewritten. * gnu/java/nio/NIOConstants.java: New file. * Makefile.am (ordinary_java_source_files): Added gnu/java/nio/NIOConstants.java. * Makefile.in: Regenerated. From-SVN: r71769
2003-09-25 12:17:00 +02:00
if (dst.hasArray())
{
2003-09-25 Michael Koch <konqueror@gmx.de> * gnu/java/nio/DatagramChannelImpl.java (DatagramChannelImpl): Made class final. (blocking): Made private. (socket): Made it a NIODatagramSocket and private. (DatagramChannelImpl): create NIODatagramSocket instead of DatagramSocket. (implConfigureBlocking): Set socket timeout. (connect): Check that channel is not closed. (write): Implemented. (write): Rewritten. (read): Implemented. (read): Rewritten. (receive): Implemented. (send): Implemented. * gnu/java/nio/SelectionKeyImpl.java (readyOps): Made private. (interestOps): Made private. (impl): Made private. (ch): Made private. (readyOps): Check if selection key is valid. (interestOps): Likewise. * gnu/java/nio/SelectorImpl.java (closed): Removed. (keys): Made private. (selected): Made private. (finalize): New method. (implCloseSelector): Rewritten. (keys): Return unmodifiable Set. (deregisterCancelledKeys): Fixed typo in method name. * gnu/java/nio/SocketChannelImpl.java (SocketChannelImpl): Made class final. (socket): Made it a NIOSocket and private. (blocking): Made private. (connected): Made private. (connectionPending): New member variable. (SocketChannelImpl): New implementation. (finalizer): Use isConnected(). (connect): Rewritten. (finishConnect): Throws IOException, implemented. (isConnectionPending): Return connectionPending. (read): Rewritten. (write): Rewritten. * gnu/java/nio/NIOConstants.java: New file. * Makefile.am (ordinary_java_source_files): Added gnu/java/nio/NIOConstants.java. * Makefile.in: Regenerated. From-SVN: r71769
2003-09-25 12:17:00 +02:00
offset = dst.arrayOffset() + dst.position();
data = dst.array();
}
else
{
2003-09-25 Michael Koch <konqueror@gmx.de> * gnu/java/nio/DatagramChannelImpl.java (DatagramChannelImpl): Made class final. (blocking): Made private. (socket): Made it a NIODatagramSocket and private. (DatagramChannelImpl): create NIODatagramSocket instead of DatagramSocket. (implConfigureBlocking): Set socket timeout. (connect): Check that channel is not closed. (write): Implemented. (write): Rewritten. (read): Implemented. (read): Rewritten. (receive): Implemented. (send): Implemented. * gnu/java/nio/SelectionKeyImpl.java (readyOps): Made private. (interestOps): Made private. (impl): Made private. (ch): Made private. (readyOps): Check if selection key is valid. (interestOps): Likewise. * gnu/java/nio/SelectorImpl.java (closed): Removed. (keys): Made private. (selected): Made private. (finalize): New method. (implCloseSelector): Rewritten. (keys): Return unmodifiable Set. (deregisterCancelledKeys): Fixed typo in method name. * gnu/java/nio/SocketChannelImpl.java (SocketChannelImpl): Made class final. (socket): Made it a NIOSocket and private. (blocking): Made private. (connected): Made private. (connectionPending): New member variable. (SocketChannelImpl): New implementation. (finalizer): Use isConnected(). (connect): Rewritten. (finishConnect): Throws IOException, implemented. (isConnectionPending): Return connectionPending. (read): Rewritten. (write): Rewritten. * gnu/java/nio/NIOConstants.java: New file. * Makefile.am (ordinary_java_source_files): Added gnu/java/nio/NIOConstants.java. * Makefile.in: Regenerated. From-SVN: r71769
2003-09-25 12:17:00 +02:00
data = new byte [len];
}
2003-09-25 Michael Koch <konqueror@gmx.de> * gnu/java/nio/DatagramChannelImpl.java (DatagramChannelImpl): Made class final. (blocking): Made private. (socket): Made it a NIODatagramSocket and private. (DatagramChannelImpl): create NIODatagramSocket instead of DatagramSocket. (implConfigureBlocking): Set socket timeout. (connect): Check that channel is not closed. (write): Implemented. (write): Rewritten. (read): Implemented. (read): Rewritten. (receive): Implemented. (send): Implemented. * gnu/java/nio/SelectionKeyImpl.java (readyOps): Made private. (interestOps): Made private. (impl): Made private. (ch): Made private. (readyOps): Check if selection key is valid. (interestOps): Likewise. * gnu/java/nio/SelectorImpl.java (closed): Removed. (keys): Made private. (selected): Made private. (finalize): New method. (implCloseSelector): Rewritten. (keys): Return unmodifiable Set. (deregisterCancelledKeys): Fixed typo in method name. * gnu/java/nio/SocketChannelImpl.java (SocketChannelImpl): Made class final. (socket): Made it a NIOSocket and private. (blocking): Made private. (connected): Made private. (connectionPending): New member variable. (SocketChannelImpl): New implementation. (finalizer): Use isConnected(). (connect): Rewritten. (finishConnect): Throws IOException, implemented. (isConnectionPending): Return connectionPending. (read): Rewritten. (write): Rewritten. * gnu/java/nio/NIOConstants.java: New file. * Makefile.am (ordinary_java_source_files): Added gnu/java/nio/NIOConstants.java. * Makefile.in: Regenerated. From-SVN: r71769
2003-09-25 12:17:00 +02:00
int readBytes = 0;
boolean completed = false;
try
{
begin();
socket.getPlainSocketImpl().setInChannelOperation(true);
2003-09-25 Michael Koch <konqueror@gmx.de> * gnu/java/nio/DatagramChannelImpl.java (DatagramChannelImpl): Made class final. (blocking): Made private. (socket): Made it a NIODatagramSocket and private. (DatagramChannelImpl): create NIODatagramSocket instead of DatagramSocket. (implConfigureBlocking): Set socket timeout. (connect): Check that channel is not closed. (write): Implemented. (write): Rewritten. (read): Implemented. (read): Rewritten. (receive): Implemented. (send): Implemented. * gnu/java/nio/SelectionKeyImpl.java (readyOps): Made private. (interestOps): Made private. (impl): Made private. (ch): Made private. (readyOps): Check if selection key is valid. (interestOps): Likewise. * gnu/java/nio/SelectorImpl.java (closed): Removed. (keys): Made private. (selected): Made private. (finalize): New method. (implCloseSelector): Rewritten. (keys): Return unmodifiable Set. (deregisterCancelledKeys): Fixed typo in method name. * gnu/java/nio/SocketChannelImpl.java (SocketChannelImpl): Made class final. (socket): Made it a NIOSocket and private. (blocking): Made private. (connected): Made private. (connectionPending): New member variable. (SocketChannelImpl): New implementation. (finalizer): Use isConnected(). (connect): Rewritten. (finishConnect): Throws IOException, implemented. (isConnectionPending): Return connectionPending. (read): Rewritten. (write): Rewritten. * gnu/java/nio/NIOConstants.java: New file. * Makefile.am (ordinary_java_source_files): Added gnu/java/nio/NIOConstants.java. * Makefile.in: Regenerated. From-SVN: r71769
2003-09-25 12:17:00 +02:00
readBytes = input.read (data, offset, len);
completed = true;
}
finally
{
end (completed);
socket.getPlainSocketImpl().setInChannelOperation(false);
2003-09-25 Michael Koch <konqueror@gmx.de> * gnu/java/nio/DatagramChannelImpl.java (DatagramChannelImpl): Made class final. (blocking): Made private. (socket): Made it a NIODatagramSocket and private. (DatagramChannelImpl): create NIODatagramSocket instead of DatagramSocket. (implConfigureBlocking): Set socket timeout. (connect): Check that channel is not closed. (write): Implemented. (write): Rewritten. (read): Implemented. (read): Rewritten. (receive): Implemented. (send): Implemented. * gnu/java/nio/SelectionKeyImpl.java (readyOps): Made private. (interestOps): Made private. (impl): Made private. (ch): Made private. (readyOps): Check if selection key is valid. (interestOps): Likewise. * gnu/java/nio/SelectorImpl.java (closed): Removed. (keys): Made private. (selected): Made private. (finalize): New method. (implCloseSelector): Rewritten. (keys): Return unmodifiable Set. (deregisterCancelledKeys): Fixed typo in method name. * gnu/java/nio/SocketChannelImpl.java (SocketChannelImpl): Made class final. (socket): Made it a NIOSocket and private. (blocking): Made private. (connected): Made private. (connectionPending): New member variable. (SocketChannelImpl): New implementation. (finalizer): Use isConnected(). (connect): Rewritten. (finishConnect): Throws IOException, implemented. (isConnectionPending): Return connectionPending. (read): Rewritten. (write): Rewritten. * gnu/java/nio/NIOConstants.java: New file. * Makefile.am (ordinary_java_source_files): Added gnu/java/nio/NIOConstants.java. * Makefile.in: Regenerated. From-SVN: r71769
2003-09-25 12:17:00 +02:00
}
if (readBytes > 0)
if (dst.hasArray())
{
dst.position (dst.position() + readBytes);
}
else
{
dst.put (data, offset, readBytes);
}
2003-09-25 Michael Koch <konqueror@gmx.de> * gnu/java/nio/DatagramChannelImpl.java (DatagramChannelImpl): Made class final. (blocking): Made private. (socket): Made it a NIODatagramSocket and private. (DatagramChannelImpl): create NIODatagramSocket instead of DatagramSocket. (implConfigureBlocking): Set socket timeout. (connect): Check that channel is not closed. (write): Implemented. (write): Rewritten. (read): Implemented. (read): Rewritten. (receive): Implemented. (send): Implemented. * gnu/java/nio/SelectionKeyImpl.java (readyOps): Made private. (interestOps): Made private. (impl): Made private. (ch): Made private. (readyOps): Check if selection key is valid. (interestOps): Likewise. * gnu/java/nio/SelectorImpl.java (closed): Removed. (keys): Made private. (selected): Made private. (finalize): New method. (implCloseSelector): Rewritten. (keys): Return unmodifiable Set. (deregisterCancelledKeys): Fixed typo in method name. * gnu/java/nio/SocketChannelImpl.java (SocketChannelImpl): Made class final. (socket): Made it a NIOSocket and private. (blocking): Made private. (connected): Made private. (connectionPending): New member variable. (SocketChannelImpl): New implementation. (finalizer): Use isConnected(). (connect): Rewritten. (finishConnect): Throws IOException, implemented. (isConnectionPending): Return connectionPending. (read): Rewritten. (write): Rewritten. * gnu/java/nio/NIOConstants.java: New file. * Makefile.am (ordinary_java_source_files): Added gnu/java/nio/NIOConstants.java. * Makefile.in: Regenerated. From-SVN: r71769
2003-09-25 12:17:00 +02:00
return readBytes;
}
public long read (ByteBuffer[] dsts, int offset, int length)
throws IOException
{
if (!isConnected())
2003-09-25 Michael Koch <konqueror@gmx.de> * gnu/java/nio/DatagramChannelImpl.java (DatagramChannelImpl): Made class final. (blocking): Made private. (socket): Made it a NIODatagramSocket and private. (DatagramChannelImpl): create NIODatagramSocket instead of DatagramSocket. (implConfigureBlocking): Set socket timeout. (connect): Check that channel is not closed. (write): Implemented. (write): Rewritten. (read): Implemented. (read): Rewritten. (receive): Implemented. (send): Implemented. * gnu/java/nio/SelectionKeyImpl.java (readyOps): Made private. (interestOps): Made private. (impl): Made private. (ch): Made private. (readyOps): Check if selection key is valid. (interestOps): Likewise. * gnu/java/nio/SelectorImpl.java (closed): Removed. (keys): Made private. (selected): Made private. (finalize): New method. (implCloseSelector): Rewritten. (keys): Return unmodifiable Set. (deregisterCancelledKeys): Fixed typo in method name. * gnu/java/nio/SocketChannelImpl.java (SocketChannelImpl): Made class final. (socket): Made it a NIOSocket and private. (blocking): Made private. (connected): Made private. (connectionPending): New member variable. (SocketChannelImpl): New implementation. (finalizer): Use isConnected(). (connect): Rewritten. (finishConnect): Throws IOException, implemented. (isConnectionPending): Return connectionPending. (read): Rewritten. (write): Rewritten. * gnu/java/nio/NIOConstants.java: New file. * Makefile.am (ordinary_java_source_files): Added gnu/java/nio/NIOConstants.java. * Makefile.in: Regenerated. From-SVN: r71769
2003-09-25 12:17:00 +02:00
throw new NotYetConnectedException();
if ((offset < 0)
|| (offset > dsts.length)
|| (length < 0)
|| (length > (dsts.length - offset)))
throw new IndexOutOfBoundsException();
long readBytes = 0;
2003-09-25 Michael Koch <konqueror@gmx.de> * gnu/java/nio/DatagramChannelImpl.java (DatagramChannelImpl): Made class final. (blocking): Made private. (socket): Made it a NIODatagramSocket and private. (DatagramChannelImpl): create NIODatagramSocket instead of DatagramSocket. (implConfigureBlocking): Set socket timeout. (connect): Check that channel is not closed. (write): Implemented. (write): Rewritten. (read): Implemented. (read): Rewritten. (receive): Implemented. (send): Implemented. * gnu/java/nio/SelectionKeyImpl.java (readyOps): Made private. (interestOps): Made private. (impl): Made private. (ch): Made private. (readyOps): Check if selection key is valid. (interestOps): Likewise. * gnu/java/nio/SelectorImpl.java (closed): Removed. (keys): Made private. (selected): Made private. (finalize): New method. (implCloseSelector): Rewritten. (keys): Return unmodifiable Set. (deregisterCancelledKeys): Fixed typo in method name. * gnu/java/nio/SocketChannelImpl.java (SocketChannelImpl): Made class final. (socket): Made it a NIOSocket and private. (blocking): Made private. (connected): Made private. (connectionPending): New member variable. (SocketChannelImpl): New implementation. (finalizer): Use isConnected(). (connect): Rewritten. (finishConnect): Throws IOException, implemented. (isConnectionPending): Return connectionPending. (read): Rewritten. (write): Rewritten. * gnu/java/nio/NIOConstants.java: New file. * Makefile.am (ordinary_java_source_files): Added gnu/java/nio/NIOConstants.java. * Makefile.in: Regenerated. From-SVN: r71769
2003-09-25 12:17:00 +02:00
for (int index = offset; index < length; index++)
readBytes += read (dsts [index]);
2003-09-25 Michael Koch <konqueror@gmx.de> * gnu/java/nio/DatagramChannelImpl.java (DatagramChannelImpl): Made class final. (blocking): Made private. (socket): Made it a NIODatagramSocket and private. (DatagramChannelImpl): create NIODatagramSocket instead of DatagramSocket. (implConfigureBlocking): Set socket timeout. (connect): Check that channel is not closed. (write): Implemented. (write): Rewritten. (read): Implemented. (read): Rewritten. (receive): Implemented. (send): Implemented. * gnu/java/nio/SelectionKeyImpl.java (readyOps): Made private. (interestOps): Made private. (impl): Made private. (ch): Made private. (readyOps): Check if selection key is valid. (interestOps): Likewise. * gnu/java/nio/SelectorImpl.java (closed): Removed. (keys): Made private. (selected): Made private. (finalize): New method. (implCloseSelector): Rewritten. (keys): Return unmodifiable Set. (deregisterCancelledKeys): Fixed typo in method name. * gnu/java/nio/SocketChannelImpl.java (SocketChannelImpl): Made class final. (socket): Made it a NIOSocket and private. (blocking): Made private. (connected): Made private. (connectionPending): New member variable. (SocketChannelImpl): New implementation. (finalizer): Use isConnected(). (connect): Rewritten. (finishConnect): Throws IOException, implemented. (isConnectionPending): Return connectionPending. (read): Rewritten. (write): Rewritten. * gnu/java/nio/NIOConstants.java: New file. * Makefile.am (ordinary_java_source_files): Added gnu/java/nio/NIOConstants.java. * Makefile.in: Regenerated. From-SVN: r71769
2003-09-25 12:17:00 +02:00
return readBytes;
}
public int write (ByteBuffer src)
throws IOException
{
if (!isConnected())
2003-09-25 Michael Koch <konqueror@gmx.de> * gnu/java/nio/DatagramChannelImpl.java (DatagramChannelImpl): Made class final. (blocking): Made private. (socket): Made it a NIODatagramSocket and private. (DatagramChannelImpl): create NIODatagramSocket instead of DatagramSocket. (implConfigureBlocking): Set socket timeout. (connect): Check that channel is not closed. (write): Implemented. (write): Rewritten. (read): Implemented. (read): Rewritten. (receive): Implemented. (send): Implemented. * gnu/java/nio/SelectionKeyImpl.java (readyOps): Made private. (interestOps): Made private. (impl): Made private. (ch): Made private. (readyOps): Check if selection key is valid. (interestOps): Likewise. * gnu/java/nio/SelectorImpl.java (closed): Removed. (keys): Made private. (selected): Made private. (finalize): New method. (implCloseSelector): Rewritten. (keys): Return unmodifiable Set. (deregisterCancelledKeys): Fixed typo in method name. * gnu/java/nio/SocketChannelImpl.java (SocketChannelImpl): Made class final. (socket): Made it a NIOSocket and private. (blocking): Made private. (connected): Made private. (connectionPending): New member variable. (SocketChannelImpl): New implementation. (finalizer): Use isConnected(). (connect): Rewritten. (finishConnect): Throws IOException, implemented. (isConnectionPending): Return connectionPending. (read): Rewritten. (write): Rewritten. * gnu/java/nio/NIOConstants.java: New file. * Makefile.am (ordinary_java_source_files): Added gnu/java/nio/NIOConstants.java. * Makefile.in: Regenerated. From-SVN: r71769
2003-09-25 12:17:00 +02:00
throw new NotYetConnectedException();
byte[] data;
2003-09-25 Michael Koch <konqueror@gmx.de> * gnu/java/nio/DatagramChannelImpl.java (DatagramChannelImpl): Made class final. (blocking): Made private. (socket): Made it a NIODatagramSocket and private. (DatagramChannelImpl): create NIODatagramSocket instead of DatagramSocket. (implConfigureBlocking): Set socket timeout. (connect): Check that channel is not closed. (write): Implemented. (write): Rewritten. (read): Implemented. (read): Rewritten. (receive): Implemented. (send): Implemented. * gnu/java/nio/SelectionKeyImpl.java (readyOps): Made private. (interestOps): Made private. (impl): Made private. (ch): Made private. (readyOps): Check if selection key is valid. (interestOps): Likewise. * gnu/java/nio/SelectorImpl.java (closed): Removed. (keys): Made private. (selected): Made private. (finalize): New method. (implCloseSelector): Rewritten. (keys): Return unmodifiable Set. (deregisterCancelledKeys): Fixed typo in method name. * gnu/java/nio/SocketChannelImpl.java (SocketChannelImpl): Made class final. (socket): Made it a NIOSocket and private. (blocking): Made private. (connected): Made private. (connectionPending): New member variable. (SocketChannelImpl): New implementation. (finalizer): Use isConnected(). (connect): Rewritten. (finishConnect): Throws IOException, implemented. (isConnectionPending): Return connectionPending. (read): Rewritten. (write): Rewritten. * gnu/java/nio/NIOConstants.java: New file. * Makefile.am (ordinary_java_source_files): Added gnu/java/nio/NIOConstants.java. * Makefile.in: Regenerated. From-SVN: r71769
2003-09-25 12:17:00 +02:00
int offset = 0;
int len = src.remaining();
2003-09-25 Michael Koch <konqueror@gmx.de> * gnu/java/nio/DatagramChannelImpl.java (DatagramChannelImpl): Made class final. (blocking): Made private. (socket): Made it a NIODatagramSocket and private. (DatagramChannelImpl): create NIODatagramSocket instead of DatagramSocket. (implConfigureBlocking): Set socket timeout. (connect): Check that channel is not closed. (write): Implemented. (write): Rewritten. (read): Implemented. (read): Rewritten. (receive): Implemented. (send): Implemented. * gnu/java/nio/SelectionKeyImpl.java (readyOps): Made private. (interestOps): Made private. (impl): Made private. (ch): Made private. (readyOps): Check if selection key is valid. (interestOps): Likewise. * gnu/java/nio/SelectorImpl.java (closed): Removed. (keys): Made private. (selected): Made private. (finalize): New method. (implCloseSelector): Rewritten. (keys): Return unmodifiable Set. (deregisterCancelledKeys): Fixed typo in method name. * gnu/java/nio/SocketChannelImpl.java (SocketChannelImpl): Made class final. (socket): Made it a NIOSocket and private. (blocking): Made private. (connected): Made private. (connectionPending): New member variable. (SocketChannelImpl): New implementation. (finalizer): Use isConnected(). (connect): Rewritten. (finishConnect): Throws IOException, implemented. (isConnectionPending): Return connectionPending. (read): Rewritten. (write): Rewritten. * gnu/java/nio/NIOConstants.java: New file. * Makefile.am (ordinary_java_source_files): Added gnu/java/nio/NIOConstants.java. * Makefile.in: Regenerated. From-SVN: r71769
2003-09-25 12:17:00 +02:00
if (!src.hasArray())
ByteBufferImpl.java, [...]: Moved files to java/nio. 2003-05-20 Michael Koch <konqueror@gmx.de> * gnu/java/nio/ByteBufferImpl.java, gnu/java/nio/CharBufferImpl.java, gnu/java/nio/CharViewBufferImpl.java, gnu/java/nio/DirectByteBufferImpl.java, gnu/java/nio/DoubleBufferImpl.java, gnu/java/nio/DoubleViewBufferImpl.java, gnu/java/nio/FloatBufferImpl.java, gnu/java/nio/FloatViewBufferImpl.java, gnu/java/nio/IntBufferImpl.java, gnu/java/nio/IntViewBufferImpl.java, gnu/java/nio/LongBufferImpl.java, gnu/java/nio/LongViewBufferImpl.java, gnu/java/nio/natDirectByteBufferImpl.cc, gnu/java/nio/ShortBufferImpl.java, gnu/java/nio/ShortViewBufferImpl.java: Moved files to java/nio. * gnu/java/nio/SocketChannelImpl.java * java/nio/ByteBuffer.java, java/nio/CharBuffer.java, java/nio/DoubleBuffer.java, java/nio/FloatBuffer.java, java/nio/IntBuffer.java, java/nio/LongBuffer.java, java/nio/ShortBuffer.java: Dont import anything. * java/nio/ByteBufferImpl.java, java/nio/CharBufferImpl.java, java/nio/CharViewBufferImpl.java, java/nio/DirectByteBufferImpl.java, java/nio/DoubleBufferImpl.java, java/nio/DoubleViewBufferImpl.java, java/nio/FloatBufferImpl.java, java/nio/FloatViewBufferImpl.java, java/nio/IntBufferImpl.java, java/nio/IntViewBufferImpl.java, java/nio/LongBufferImpl.java, java/nio/LongViewBufferImpl.java, java/nio/natDirectByteBufferImpl.cc, java/nio/ShortBufferImpl.java, java/nio/ShortViewBufferImpl.java: Moved from gnu/java/nio. * Makefile.am (ordinary_java_source_files): Moved files from gnu/java/nio to java/nio. (nat_source_files): Moved natDirectByteBufferImpl.cc from gnu/java/nio to java/nio. * Makefile.in: Regenerated. From-SVN: r66990
2003-05-20 10:58:31 +02:00
{
data = new byte [len];
src.get (data, 0, len);
ByteBufferImpl.java, [...]: Moved files to java/nio. 2003-05-20 Michael Koch <konqueror@gmx.de> * gnu/java/nio/ByteBufferImpl.java, gnu/java/nio/CharBufferImpl.java, gnu/java/nio/CharViewBufferImpl.java, gnu/java/nio/DirectByteBufferImpl.java, gnu/java/nio/DoubleBufferImpl.java, gnu/java/nio/DoubleViewBufferImpl.java, gnu/java/nio/FloatBufferImpl.java, gnu/java/nio/FloatViewBufferImpl.java, gnu/java/nio/IntBufferImpl.java, gnu/java/nio/IntViewBufferImpl.java, gnu/java/nio/LongBufferImpl.java, gnu/java/nio/LongViewBufferImpl.java, gnu/java/nio/natDirectByteBufferImpl.cc, gnu/java/nio/ShortBufferImpl.java, gnu/java/nio/ShortViewBufferImpl.java: Moved files to java/nio. * gnu/java/nio/SocketChannelImpl.java * java/nio/ByteBuffer.java, java/nio/CharBuffer.java, java/nio/DoubleBuffer.java, java/nio/FloatBuffer.java, java/nio/IntBuffer.java, java/nio/LongBuffer.java, java/nio/ShortBuffer.java: Dont import anything. * java/nio/ByteBufferImpl.java, java/nio/CharBufferImpl.java, java/nio/CharViewBufferImpl.java, java/nio/DirectByteBufferImpl.java, java/nio/DoubleBufferImpl.java, java/nio/DoubleViewBufferImpl.java, java/nio/FloatBufferImpl.java, java/nio/FloatViewBufferImpl.java, java/nio/IntBufferImpl.java, java/nio/IntViewBufferImpl.java, java/nio/LongBufferImpl.java, java/nio/LongViewBufferImpl.java, java/nio/natDirectByteBufferImpl.cc, java/nio/ShortBufferImpl.java, java/nio/ShortViewBufferImpl.java: Moved from gnu/java/nio. * Makefile.am (ordinary_java_source_files): Moved files from gnu/java/nio to java/nio. (nat_source_files): Moved natDirectByteBufferImpl.cc from gnu/java/nio to java/nio. * Makefile.in: Regenerated. From-SVN: r66990
2003-05-20 10:58:31 +02:00
}
else
ByteBufferImpl.java, [...]: Moved files to java/nio. 2003-05-20 Michael Koch <konqueror@gmx.de> * gnu/java/nio/ByteBufferImpl.java, gnu/java/nio/CharBufferImpl.java, gnu/java/nio/CharViewBufferImpl.java, gnu/java/nio/DirectByteBufferImpl.java, gnu/java/nio/DoubleBufferImpl.java, gnu/java/nio/DoubleViewBufferImpl.java, gnu/java/nio/FloatBufferImpl.java, gnu/java/nio/FloatViewBufferImpl.java, gnu/java/nio/IntBufferImpl.java, gnu/java/nio/IntViewBufferImpl.java, gnu/java/nio/LongBufferImpl.java, gnu/java/nio/LongViewBufferImpl.java, gnu/java/nio/natDirectByteBufferImpl.cc, gnu/java/nio/ShortBufferImpl.java, gnu/java/nio/ShortViewBufferImpl.java: Moved files to java/nio. * gnu/java/nio/SocketChannelImpl.java * java/nio/ByteBuffer.java, java/nio/CharBuffer.java, java/nio/DoubleBuffer.java, java/nio/FloatBuffer.java, java/nio/IntBuffer.java, java/nio/LongBuffer.java, java/nio/ShortBuffer.java: Dont import anything. * java/nio/ByteBufferImpl.java, java/nio/CharBufferImpl.java, java/nio/CharViewBufferImpl.java, java/nio/DirectByteBufferImpl.java, java/nio/DoubleBufferImpl.java, java/nio/DoubleViewBufferImpl.java, java/nio/FloatBufferImpl.java, java/nio/FloatViewBufferImpl.java, java/nio/IntBufferImpl.java, java/nio/IntViewBufferImpl.java, java/nio/LongBufferImpl.java, java/nio/LongViewBufferImpl.java, java/nio/natDirectByteBufferImpl.cc, java/nio/ShortBufferImpl.java, java/nio/ShortViewBufferImpl.java: Moved from gnu/java/nio. * Makefile.am (ordinary_java_source_files): Moved files from gnu/java/nio to java/nio. (nat_source_files): Moved natDirectByteBufferImpl.cc from gnu/java/nio to java/nio. * Makefile.in: Regenerated. From-SVN: r66990
2003-05-20 10:58:31 +02:00
{
2003-09-25 Michael Koch <konqueror@gmx.de> * gnu/java/nio/DatagramChannelImpl.java (DatagramChannelImpl): Made class final. (blocking): Made private. (socket): Made it a NIODatagramSocket and private. (DatagramChannelImpl): create NIODatagramSocket instead of DatagramSocket. (implConfigureBlocking): Set socket timeout. (connect): Check that channel is not closed. (write): Implemented. (write): Rewritten. (read): Implemented. (read): Rewritten. (receive): Implemented. (send): Implemented. * gnu/java/nio/SelectionKeyImpl.java (readyOps): Made private. (interestOps): Made private. (impl): Made private. (ch): Made private. (readyOps): Check if selection key is valid. (interestOps): Likewise. * gnu/java/nio/SelectorImpl.java (closed): Removed. (keys): Made private. (selected): Made private. (finalize): New method. (implCloseSelector): Rewritten. (keys): Return unmodifiable Set. (deregisterCancelledKeys): Fixed typo in method name. * gnu/java/nio/SocketChannelImpl.java (SocketChannelImpl): Made class final. (socket): Made it a NIOSocket and private. (blocking): Made private. (connected): Made private. (connectionPending): New member variable. (SocketChannelImpl): New implementation. (finalizer): Use isConnected(). (connect): Rewritten. (finishConnect): Throws IOException, implemented. (isConnectionPending): Return connectionPending. (read): Rewritten. (write): Rewritten. * gnu/java/nio/NIOConstants.java: New file. * Makefile.am (ordinary_java_source_files): Added gnu/java/nio/NIOConstants.java. * Makefile.in: Regenerated. From-SVN: r71769
2003-09-25 12:17:00 +02:00
offset = src.arrayOffset() + src.position();
data = src.array();
ByteBufferImpl.java, [...]: Moved files to java/nio. 2003-05-20 Michael Koch <konqueror@gmx.de> * gnu/java/nio/ByteBufferImpl.java, gnu/java/nio/CharBufferImpl.java, gnu/java/nio/CharViewBufferImpl.java, gnu/java/nio/DirectByteBufferImpl.java, gnu/java/nio/DoubleBufferImpl.java, gnu/java/nio/DoubleViewBufferImpl.java, gnu/java/nio/FloatBufferImpl.java, gnu/java/nio/FloatViewBufferImpl.java, gnu/java/nio/IntBufferImpl.java, gnu/java/nio/IntViewBufferImpl.java, gnu/java/nio/LongBufferImpl.java, gnu/java/nio/LongViewBufferImpl.java, gnu/java/nio/natDirectByteBufferImpl.cc, gnu/java/nio/ShortBufferImpl.java, gnu/java/nio/ShortViewBufferImpl.java: Moved files to java/nio. * gnu/java/nio/SocketChannelImpl.java * java/nio/ByteBuffer.java, java/nio/CharBuffer.java, java/nio/DoubleBuffer.java, java/nio/FloatBuffer.java, java/nio/IntBuffer.java, java/nio/LongBuffer.java, java/nio/ShortBuffer.java: Dont import anything. * java/nio/ByteBufferImpl.java, java/nio/CharBufferImpl.java, java/nio/CharViewBufferImpl.java, java/nio/DirectByteBufferImpl.java, java/nio/DoubleBufferImpl.java, java/nio/DoubleViewBufferImpl.java, java/nio/FloatBufferImpl.java, java/nio/FloatViewBufferImpl.java, java/nio/IntBufferImpl.java, java/nio/IntViewBufferImpl.java, java/nio/LongBufferImpl.java, java/nio/LongViewBufferImpl.java, java/nio/natDirectByteBufferImpl.cc, java/nio/ShortBufferImpl.java, java/nio/ShortViewBufferImpl.java: Moved from gnu/java/nio. * Makefile.am (ordinary_java_source_files): Moved files from gnu/java/nio to java/nio. (nat_source_files): Moved natDirectByteBufferImpl.cc from gnu/java/nio to java/nio. * Makefile.in: Regenerated. From-SVN: r66990
2003-05-20 10:58:31 +02:00
}
2003-09-25 Michael Koch <konqueror@gmx.de> * gnu/java/nio/DatagramChannelImpl.java (DatagramChannelImpl): Made class final. (blocking): Made private. (socket): Made it a NIODatagramSocket and private. (DatagramChannelImpl): create NIODatagramSocket instead of DatagramSocket. (implConfigureBlocking): Set socket timeout. (connect): Check that channel is not closed. (write): Implemented. (write): Rewritten. (read): Implemented. (read): Rewritten. (receive): Implemented. (send): Implemented. * gnu/java/nio/SelectionKeyImpl.java (readyOps): Made private. (interestOps): Made private. (impl): Made private. (ch): Made private. (readyOps): Check if selection key is valid. (interestOps): Likewise. * gnu/java/nio/SelectorImpl.java (closed): Removed. (keys): Made private. (selected): Made private. (finalize): New method. (implCloseSelector): Rewritten. (keys): Return unmodifiable Set. (deregisterCancelledKeys): Fixed typo in method name. * gnu/java/nio/SocketChannelImpl.java (SocketChannelImpl): Made class final. (socket): Made it a NIOSocket and private. (blocking): Made private. (connected): Made private. (connectionPending): New member variable. (SocketChannelImpl): New implementation. (finalizer): Use isConnected(). (connect): Rewritten. (finishConnect): Throws IOException, implemented. (isConnectionPending): Return connectionPending. (read): Rewritten. (write): Rewritten. * gnu/java/nio/NIOConstants.java: New file. * Makefile.am (ordinary_java_source_files): Added gnu/java/nio/NIOConstants.java. * Makefile.in: Regenerated. From-SVN: r71769
2003-09-25 12:17:00 +02:00
OutputStream output = socket.getOutputStream();
boolean completed = false;
try
{
begin();
socket.getPlainSocketImpl().setInChannelOperation(true);
output.write (data, offset, len);
completed = true;
}
finally
{
end (completed);
socket.getPlainSocketImpl().setInChannelOperation(false);
}
if (src.hasArray())
{
src.position (src.position() + len);
}
return len;
}
public long write (ByteBuffer[] srcs, int offset, int length)
throws IOException
{
if (!isConnected())
2003-09-25 Michael Koch <konqueror@gmx.de> * gnu/java/nio/DatagramChannelImpl.java (DatagramChannelImpl): Made class final. (blocking): Made private. (socket): Made it a NIODatagramSocket and private. (DatagramChannelImpl): create NIODatagramSocket instead of DatagramSocket. (implConfigureBlocking): Set socket timeout. (connect): Check that channel is not closed. (write): Implemented. (write): Rewritten. (read): Implemented. (read): Rewritten. (receive): Implemented. (send): Implemented. * gnu/java/nio/SelectionKeyImpl.java (readyOps): Made private. (interestOps): Made private. (impl): Made private. (ch): Made private. (readyOps): Check if selection key is valid. (interestOps): Likewise. * gnu/java/nio/SelectorImpl.java (closed): Removed. (keys): Made private. (selected): Made private. (finalize): New method. (implCloseSelector): Rewritten. (keys): Return unmodifiable Set. (deregisterCancelledKeys): Fixed typo in method name. * gnu/java/nio/SocketChannelImpl.java (SocketChannelImpl): Made class final. (socket): Made it a NIOSocket and private. (blocking): Made private. (connected): Made private. (connectionPending): New member variable. (SocketChannelImpl): New implementation. (finalizer): Use isConnected(). (connect): Rewritten. (finishConnect): Throws IOException, implemented. (isConnectionPending): Return connectionPending. (read): Rewritten. (write): Rewritten. * gnu/java/nio/NIOConstants.java: New file. * Makefile.am (ordinary_java_source_files): Added gnu/java/nio/NIOConstants.java. * Makefile.in: Regenerated. From-SVN: r71769
2003-09-25 12:17:00 +02:00
throw new NotYetConnectedException();
if ((offset < 0)
|| (offset > srcs.length)
|| (length < 0)
|| (length > (srcs.length - offset)))
throw new IndexOutOfBoundsException();
long writtenBytes = 0;
2003-09-25 Michael Koch <konqueror@gmx.de> * gnu/java/nio/DatagramChannelImpl.java (DatagramChannelImpl): Made class final. (blocking): Made private. (socket): Made it a NIODatagramSocket and private. (DatagramChannelImpl): create NIODatagramSocket instead of DatagramSocket. (implConfigureBlocking): Set socket timeout. (connect): Check that channel is not closed. (write): Implemented. (write): Rewritten. (read): Implemented. (read): Rewritten. (receive): Implemented. (send): Implemented. * gnu/java/nio/SelectionKeyImpl.java (readyOps): Made private. (interestOps): Made private. (impl): Made private. (ch): Made private. (readyOps): Check if selection key is valid. (interestOps): Likewise. * gnu/java/nio/SelectorImpl.java (closed): Removed. (keys): Made private. (selected): Made private. (finalize): New method. (implCloseSelector): Rewritten. (keys): Return unmodifiable Set. (deregisterCancelledKeys): Fixed typo in method name. * gnu/java/nio/SocketChannelImpl.java (SocketChannelImpl): Made class final. (socket): Made it a NIOSocket and private. (blocking): Made private. (connected): Made private. (connectionPending): New member variable. (SocketChannelImpl): New implementation. (finalizer): Use isConnected(). (connect): Rewritten. (finishConnect): Throws IOException, implemented. (isConnectionPending): Return connectionPending. (read): Rewritten. (write): Rewritten. * gnu/java/nio/NIOConstants.java: New file. * Makefile.am (ordinary_java_source_files): Added gnu/java/nio/NIOConstants.java. * Makefile.in: Regenerated. From-SVN: r71769
2003-09-25 12:17:00 +02:00
for (int index = offset; index < length; index++)
writtenBytes += write (srcs [index]);
2003-09-25 Michael Koch <konqueror@gmx.de> * gnu/java/nio/DatagramChannelImpl.java (DatagramChannelImpl): Made class final. (blocking): Made private. (socket): Made it a NIODatagramSocket and private. (DatagramChannelImpl): create NIODatagramSocket instead of DatagramSocket. (implConfigureBlocking): Set socket timeout. (connect): Check that channel is not closed. (write): Implemented. (write): Rewritten. (read): Implemented. (read): Rewritten. (receive): Implemented. (send): Implemented. * gnu/java/nio/SelectionKeyImpl.java (readyOps): Made private. (interestOps): Made private. (impl): Made private. (ch): Made private. (readyOps): Check if selection key is valid. (interestOps): Likewise. * gnu/java/nio/SelectorImpl.java (closed): Removed. (keys): Made private. (selected): Made private. (finalize): New method. (implCloseSelector): Rewritten. (keys): Return unmodifiable Set. (deregisterCancelledKeys): Fixed typo in method name. * gnu/java/nio/SocketChannelImpl.java (SocketChannelImpl): Made class final. (socket): Made it a NIOSocket and private. (blocking): Made private. (connected): Made private. (connectionPending): New member variable. (SocketChannelImpl): New implementation. (finalizer): Use isConnected(). (connect): Rewritten. (finishConnect): Throws IOException, implemented. (isConnectionPending): Return connectionPending. (read): Rewritten. (write): Rewritten. * gnu/java/nio/NIOConstants.java: New file. * Makefile.am (ordinary_java_source_files): Added gnu/java/nio/NIOConstants.java. * Makefile.in: Regenerated. From-SVN: r71769
2003-09-25 12:17:00 +02:00
return writtenBytes;
}
}