History log of /libcore/harmony-tests/src/test/java/org/apache/harmony/tests/java/net/DatagramSocketTest.java
Revision Date Author Comments
6566167989735858978d062a4385104ce5eca7e3 20-Jan-2016 Neil Fuller <nfuller@google.com> Allow some rounding on SO_TIMEOUT values

Kernels can round the value in use depending on the HZ setting.
This change allows up to 10ms of slop between the SO_TIMEOUT
value set and the one returned.

Bug: 26583607
Change-Id: I527987de20a6e10172656e1f0beeaf63419ffd77
49f2d45b30c55a4e55dd19886b1c0ed7ba23fc52 02-Jun-2015 Neil Fuller <nfuller@google.com> Avoid binding a DatagramSocket before setReuseAddress

The API docs suggest the behavior of setResueAddress is undefined
if performed after a socket bind. In reality Android can cope with
it but it is easier to stop relying on that than make excuses.

Bug: 15413832
Change-Id: Ic4c19d58b410e7af9019a1727dc2b7b94e9fb81b
72ed50d1e9048b79efdb5b9e4ffb07c99a302d84 16-Jan-2015 Lorenzo Colitti <lorenzo@google.com> Use the IPv6 instead of the IPv4 wildcard address in sockets.

A few places in libcore consider the local address of an unbound
socket to be Inet4Address.ANY. For example, calling
getLocalAddress on an uncreated Socket will return 0.0.0.0, and
when creating a DatagramSocket, libcore attempts to bind it to
0.0.0.0 unless the caller specifies another address.

On Android, this is incorrect. All native socket filedescriptors
that underpin Java socket objects are created by IoBridge.socket,
and are dual-stack AF_INET6 sockets, not AF_INET sockets. When
such a socket is created, its local address is ::, not 0.0.0.0.
Thus, for example, calling getLocalAddress on a just-created
ServerSocket object will return ::. Binding to 0.0.0.0 is not
even allowed by os.bind, which silently converts it to :: instead
(in inetAddresstoSockaddr).

Therefore, accept reality and use :: instead of 0.0.0.0 in the
Java layer as well. Specifically:

1. Change DatagramSocket's constructors to bind to :: instead of
0.0.0.0. This is a complete no-op, because os.bind() silently
converts 0.0.0.0 into ::. Add a test for the other of the two
codepaths.
2. Change InetSocketAddress so that an uninitialized object has
an IP address of :: and not 0.0.0.0, and update its test. This
is unlikely to break anything short of an app that explicitly
depends on this behaviour, because os.bind() converts 0.0.0.0
to ::, and because any SocketAddress returned by any real
socket will never contain 0.0.0.0 anyway.
3. Change Socket so that calling getLocalAddress() when there is
no underlying socket file descriptor is will return :: instead
of 0.0.0.0. This is more correct, because it's consistent with
sockets that have been created, which will never have a local
address of 0.0.0.0.

Tested: vogar $(find libcore/*Socket*Test*) all passes on device.

Bug: 18094870
Change-Id: I9d60710fe945a99d6a5e65430248a889008ef4b1
82c642531ba3c9ad29cb3125f7547a226b661b11 02-Jan-2014 Narayan Kamath <narayan@google.com> Delete Support_PortManager & OldDatagramSocketTest

Support_PortManager didn't really work, so rewrite all tests
that use it.

Also, dedup OldDatagramSocketTest with the harmony DatagramSocketTest.

Fix various broken test cases and terribly written tests.

bug: 11689863

Change-Id: I4efb9e02eb88517273fff50a0dec1d0262feafb2
ab762bb740405d0fefcccf4a0899a234f995be13 15-Nov-2013 Narayan Kamath <narayan@google.com> Move tests from tests/api to harmony-tests. (Take 2)

This reverts commit d5e281743e55e1daa297fd8043b2d9b6e8e1bed2.

The makefile issue that caused the original build break
has been resolved.
d5e281743e55e1daa297fd8043b2d9b6e8e1bed2 15-Nov-2013 Narayan Kamath <narayan@google.com> Revert "Move tests from tests/api to harmony-tests."

This reverts commit 81bf28ad31131815d0a36a43a0eca3c29aefdfcd.

Breaks build

Change-Id: I3f1562921ffe8fdbec36971dd65db398c27c92db
81bf28ad31131815d0a36a43a0eca3c29aefdfcd 15-Nov-2013 Narayan Kamath <narayan@google.com> Move tests from tests/api to harmony-tests.

The vast majority of cleaned up harmony tests
are now in harmony-tests/src/test/org/apache/harmony/tests/

Change-Id: I56c2e484ff434b5618cf6751d602ae9f0db96b30