History log of /libcore/luni/src/test/java/libcore/java/nio/channels/SocketChannelTest.java
Revision Date Author Comments
e5f08c57bc21f73466326ac0f505ef34d3a362de 01-Apr-2016 Shubham Ajmera <shubhamajmera@google.com> Add Unit Tests

Unit test added for:
DatagramChannel.bind(java.net.SocketAddress)
DatagramChannel.getRemoteAddress()
ServerSocketChannel.bind(java.net.SocketAddress, int)
ServerSocketChannel.bind(java.net.SocketAddress)
ServerSocketChannel.setOption(java.net.SocketOption, T)
SocketChannel.bind(java.net.SocketAddress)
SocketChannel.getRemoteAddress(java.nio.channels)
SocketChannel.shutdownInput()
SocketChannel.shutdownOutput()

Bug: 27466931
Change-Id: I0004329d71b1ce113d8dd6d9b72fa0f630d7b060
aff7af3b344bf882620489631633e09fabfcd58d 19-Feb-2016 Narayan Kamath <narayan@google.com> nio: Add unit tests for setOption / getOption.

This also revealed an asymmetry in our APIs. The class defined
setOption but was missing a getOption method (inherited from
NetworkChannel).

bug: 27186457

(cherry-picked from commit dbbe65b6a81ad02bc3bd432f21dccce6c0242cdb)

Change-Id: I823af602b258bfc5f7508dc767af7f8dc4fcf537
dbbe65b6a81ad02bc3bd432f21dccce6c0242cdb 19-Feb-2016 Narayan Kamath <narayan@google.com> nio: Add unit tests for setOption / getOption.

This also revealed an asymmetry in our APIs. The class defined
setOption but was missing a getOption method (inherited from
NetworkChannel).

bug: 27186457

Change-Id: I823af602b258bfc5f7508dc767af7f8dc4fcf537
1cb7758226b1bd3c8f39d9adb9068b02a18fcc7c 03-Feb-2016 Kenny Root <kroot@google.com> Add hack to make sure Socket#impl field is not null

Conscrypt's compat code inspects the "impl" field of Socket and expects
it to be non-null. However, SocketChannel creates an adaptor that sets
the impl field to non-null. This can't be fixed immediately, so put this
in to maintain the old behavior.

Bug: 25857624
Change-Id: I2d79a6d9a77d9102203cfb43df09d70aff99ffe3
11823c0942e6f9756b0a8bcfec386d9a64fc8a9a 05-Jan-2016 Przemyslaw Szczepaniak <pszczepaniak@google.com> Make sun.nio.ch.Net#connect throw ConnectException on error

openJdk7 SocketChannelImpl#connect throws SocketException when
the connect syscall fails. Pre-enso implementation thrown
ConnectException in this case. This change updates enso code
to throw the ConnectException.

Fixed #test_56684 test by trying to connect to 255.255.255.255,
which produces ENETUNREACH, like the pre-enso mock.

Bug: 25898575
Change-Id: I74212d03189a8d4a755c7cf328d5955368b32efc
0aff1dd0b4be1b8d8cb45b59079ca883a1b3205a 17-Jun-2014 Elliott Hughes <enh@google.com> Remove.

(cherry-pick of 63744c884dd4b4f4307f2b021fb894af164972af.)

Change-Id: Ibf79a402e1bad98a262e380fcee3d35c127ae6d5
63744c884dd4b4f4307f2b021fb894af164972af 17-Jun-2014 Elliott Hughes <enh@google.com> Remove.

Change-Id: Ibf79a402e1bad98a262e380fcee3d35c127ae6d5
5d930cadc8f62aee5f18e7921296fe66a54f18ab 24-Apr-2014 Elliott Hughes <enh@google.com> Groundwork towards making the Libcore.os functionality public.

Change-Id: Ie700aa16d91fba53fc5eb2555829cb74d84b12ad
df29508a7aa622f265aaebdc472eb7d679185ebb 30-Jan-2014 Neil Fuller <nfuller@google.com> Implementation of MulticastChannel.

Note: ProtocolFamily / StandardProtocolFamily /
DatagramChannel.open(ProtocolFamily) have not been
implemented.

There is a related change to libnativehelper that
must be merged at the same time to avoid
build breakage. See
https://android-review.googlesource.com/#/c/81371/

Bug: 12464155
Change-Id: I07fc049b429a2d373e9bd7b07149632f5cd69f9d
ff81b740a338ba964e0ba1c40d925fb2ceb37bf2 20-Jan-2014 Neil Fuller <nfuller@google.com> Adding additional methods to NetworkChannel.

Adding NetworkChannel.supportedOptions(), NetworkChannel.getOption(),
NetworkChannel.setOption(). A lot of the changes are in documentation
and tests.

Bug: 12464155
Change-Id: Ifa56843a8823b6b9cbd262409adc2450b401c654
47ae0b5a1d96c8030e0963ccc5b44c3ee66aaec3 20-Jan-2014 Neil Fuller <nfuller@google.com> Implementing bind() and getLocalAddress() for NIO2.

This change introduces NetworkChannel, but only bind() and
getLocalAddress() methods. To avoid breaking existing Android
applications that extend ServerSocketChannel, DatagramChannel and
SocketChannel the methods have been added with concrete
implementations that throw exceptions rather than leaving them
abstract.

In channel tests, usages of channel.socket().bind() and
channel.socket().getLocalSocketAddress() have been changed to
channel.bind() and channel.getLocalAddress(), since the behavior is
close enough and the tests should be written against the channel APIs
as much as possible. Tests have been added for new methods.

Removed further overriding in
DatagramChannelImpl.DatagramSocketAdapter and
SocketChannelImpl.SocketAdapter which revealed some bugs and lack of
clarity in the docs for the socket methods:

Improved the documentation for DatagramSocket.getLocalAddress(),
DatagramSocket.getLocalSocketAddress(),
ServerSocket.getInetAddress(), ServerSocket.getLocalPort(),
ServerSocket.getLocalSocketAddress(), Socket.getLocalAddress(),
Socket.getLocalPort(), Socket.getLocalSocketAddress(). These methods
treat special cases differently.

Fixed a bug in DatagramSocket.getLocalSocketAddress() where it would
incorrect throw an exception if the socket has been closed, which
contradicts the (updated) documentation and the RI. It now returns
null. Added tests.

Fixed a bug in Socket.close(): a closed socket would still report as
being connected. Added tests.

Fixed a bug in Socket.startupSocket() - the socket was recording it
was being bound, but was not updating the cached local address. This
method is called during ServerSocketChannel.accept() and would cause
the socket to report its local address as being the wildcard address,
when it is not. Added a test.

Change-Id: Ibec8527e1c72597e268d23e6c1f03eb16e46cdc4
Bug: 12464155
933fbbf606268eec9fc430632b8bca7002a833b3 14-Jan-2014 Neil Fuller <nfuller@google.com> Refactoring in preparation for NIO2 changes.

Making the various Socket/Channel classes more consistent with each
other for synchronizing state between the Channel, Socket and the OS.
This is in preparation for NetworkChannel.bind().
Synchronizing state revealed a test that relied upon a Socket from a
channel not reporting isConnected() properly after a connect(). Tests
have been updated.

Reading the local address back from the OS revealed that Android is
using IPv6 and reports the string equivalent of IPv4's 0.0.0.0 as
"::". Updated a test that was relying on the string form.

Calling connect() twice on a DatagramSocket appears inconsistent with
itself and Channel and other Sockets. A pure DatagramSocket switches
over to the new remote address. I have changed the Channel-backed
DatagramSocket to throw an IllegalStateException exception, and have
created a bug to discuss making the calls more consistent.

Socket has been modified to avoid using the address field to store
the local address after a bind(). This field is documented as holding
the remote address, not the local.

Changed implementation of SocketChannelImpl.socket().getInputStream()
and SocketChannelImpl.socket().getOutputStream() to use the one that
is implemented by Socket and not a custom NIO-based implementation.
The use of NIO provided two parallel implementations for the same
thing. This change alters behavior when attempting to read zero bytes
and when a Channel is in non-blocking mode: now it throws
IllegalBlockingModeException rather than
ArrayIndexOutOfBoundsException. The tests have been updated.

Various tidying up changes to introduce @Override, remove
unnecessarily initialized local variables, fields, semi-colons,
javadocs and imports. Added close() calls for objects during tests
that were cluttering the logs.

Modified IoBridge.connect() to be void. Adjusted SocketChannelImpl
accordingly and tidied up impossible cases. Modified
SocketChannel.connect() so that it always returns false in
non-blocking mode. This looks like an existing bug:
it would previously have returned true, even though the connection
was potentially still pending. Tests have been added.

Also tidied up SocketChannelImpl.finishConnect() - it was potentially
resetting the isBound state.

Change-Id: Ic7943615b4b763f77e74397e0e91a62edc7d7017
bug: 12464155
c43083ece7c4479fbe38001983a0d28893d0812a 22-Jun-2013 Elliott Hughes <enh@google.com> Fix the SocketChannel accept locking behavior.

Fixes a harmony-tests/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/ServerSocketChannelTest
test that had been failing since we turned it back on.

Change-Id: I76cbc5edc1ab9edc4d2818bd23649f4b906d662c
c6ad01d286af243fd300dd105eb2e4437e0b6b16 21-Jun-2013 Elliott Hughes <enh@google.com> Fix non-blocking SocketChannel connects.

There are many reasons why the initial connect(2) may have resulted
in a ConnectException, only one of which (EINPROGRESS) means we haven't
yet failed.

Bug: https://code.google.com/p/android/issues/detail?id=56684
Change-Id: I2115998bce9043f076418fb0d1c22a26e04ee2e1
4557728efb66c455a52b7669a8eefef7a9e54854 11-Aug-2010 Jesse Wilson <jessewilson@google.com> Moving tests to be under the libcore.* package.

This is indended to make it easier to run on VMs that restrict the packages
from which application classes can be loaded. For example, on the RI you need
to use the bootclasspath to load these tests.

Change-Id: I52193f35c5fcca18b5a3e1d280505b1e29b388af