Skip to content

Commit

Permalink
8319417: (dc) DatagramChannel.connect undocumented behavior
Browse files Browse the repository at this point in the history
Reviewed-by: alanb
  • Loading branch information
Michael-Mc-Mahon authored and pull[bot] committed Jun 2, 2024
1 parent 5124715 commit 8182774
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/java.base/share/classes/java/net/DatagramSocket.java
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,12 @@ public SocketAddress getRemoteSocketAddress() {

/**
* Returns the address of the endpoint this socket is bound to.
* <p>If the socket was initially bound to the wildcard address and
* is now {@link #isConnected connected}, then the address returned
* may be the local address selected as the source address for
* datagrams sent on this socket instead of the wildcard address.
* When {@link #disconnect()} is called, the bound address reverts
* to the wildcard address.
*
* @return a {@code SocketAddress} representing the local endpoint of this
* socket, or {@code null} if it is closed or not bound yet.
Expand Down Expand Up @@ -714,6 +720,12 @@ public void receive(DatagramPacket p) throws IOException {

/**
* Gets the local address to which the socket is bound.
* <p>If the socket was initially bound to the wildcard address and
* is now {@link #isConnected connected}, then the address returned
* may be the local address selected as the source address for
* datagrams sent on the socket instead of the wildcard address.
* When {@link #disconnect()} is called, the bound address reverts
* to the wildcard address.
*
* <p>If there is a security manager, its
* {@code checkConnect} method is first called
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,13 @@ public final long write(ByteBuffer[] srcs) throws IOException {
/**
* {@inheritDoc}
* <p>
* If the channel's socket was initially bound to the wildcard address and
* is now {@link #isConnected connected}, then the address returned
* may be the local address selected as the source address for
* datagrams sent via this channel instead of the wildcard address.
* When {@link #disconnect} is called, the bound address reverts
* to the wildcard address.
* <p>
* If there is a security manager set, its {@code checkConnect} method is
* called with the local address and {@code -1} as its arguments to see
* if the operation is allowed. If the operation is not allowed,
Expand Down

0 comments on commit 8182774

Please sign in to comment.