* [PATCH mptcp-next 0/7] Add MPTCP support to Java Networking API
@ 2025-07-23 5:16 Geliang Tang
2025-07-23 5:16 ` [PATCH mptcp-next 1/7] Add MPTCP support for socket creation Geliang Tang
` (7 more replies)
0 siblings, 8 replies; 16+ messages in thread
From: Geliang Tang @ 2025-07-23 5:16 UTC (permalink / raw)
To: mptcp; +Cc: Geliang Tang
The Multipath TCP (MPTCP) protocol (v1 / RFC 8684) has been added in
the upstream Linux kernel since v5.6.
This patch series introduces comprehensive Multipath TCP (MPTCP) support
to the Java Networking API, enabling applications to leverage MPTCP's
capabilities for improved reliability and throughput.
The implementation provides:
1. Core infrastructure for MPTCP socket creation (Patch 1)
2. Server and client socket creation APIs (Patches 2-3)
3. Integration with NIO socket implementation (Patch 4)
4. High-level Socket and ServerSocket support (Patches 5-6)
5. Comprehensive test cases (Patch 7)
Key features:
- Backward compatible API extensions
- Platform-independent implementation
- Explicit MPTCP enablement through new constructors
- Full integration with existing socket functionality
- Test coverage for basic MPTCP operations
The changes maintain all existing functionality while adding MPTCP
capabilities. When MPTCP is not enabled or not supported by the system, the
implementation gracefully falls back to regular TCP behavior.
This work enables Java applications to benefit from MPTCP's capabilities:
- Seamless handover between network interfaces
- Aggregated bandwidth from multiple paths
- Improved resilience to network failures
The implementation has been tested on Linux systems with MPTCP kernel
support enabled.
https://github.com/openjdk/jdk
Geliang Tang (7):
Add MPTCP support for socket creation
Add MPTCP server socket creation support
Add MPTCP client socket creation support
Add MPTCP support to NioSocketImpl
Add MPTCP support to ServerSocket class
Add MPTCP support to Socket class
Add test cases for MPTCP socket functionality
.../share/classes/java/net/ServerSocket.java | 66 ++++++++++++++
.../share/classes/java/net/Socket.java | 88 +++++++++++++++++++
.../share/classes/java/net/SocketImpl.java | 8 ++
.../share/classes/sun/nio/ch/Net.java | 26 +++++-
.../classes/sun/nio/ch/NioSocketImpl.java | 19 +++-
src/java.base/unix/native/libnio/ch/Net.c | 5 +-
src/java.base/windows/native/libnio/ch/Net.c | 2 +-
.../java/net/ServerSocket/MPTCPServer.java | 58 ++++++++++++
test/jdk/java/net/Socket/MPTCPClient.java | 62 +++++++++++++
9 files changed, 326 insertions(+), 8 deletions(-)
create mode 100644 test/jdk/java/net/ServerSocket/MPTCPServer.java
create mode 100644 test/jdk/java/net/Socket/MPTCPClient.java
--
2.48.1
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH mptcp-next 1/7] Add MPTCP support for socket creation
2025-07-23 5:16 [PATCH mptcp-next 0/7] Add MPTCP support to Java Networking API Geliang Tang
@ 2025-07-23 5:16 ` Geliang Tang
2025-07-30 22:03 ` Matthieu Baerts
2025-07-23 5:16 ` [PATCH mptcp-next 2/7] Add MPTCP server socket creation support Geliang Tang
` (6 subsequent siblings)
7 siblings, 1 reply; 16+ messages in thread
From: Geliang Tang @ 2025-07-23 5:16 UTC (permalink / raw)
To: mptcp; +Cc: Geliang Tang, Gang Yan
This patch extends the socket creation functionality to support Multipath
TCP (MPTCP) by adding a new 'mptcp' parameter to the native socket0 method.
When enabled, the socket will be created with the IPPROTO_MPTCP protocol
for stream sockets.
The changes include:
1. Added the 'mptcp' parameter to socket0 method declarations in Net.java
2. Modified the native implementations in both Unix and Windows Net.c files
to handle the new parameter and set the appropriate protocol
3. Updated all call sites to pass 'false' for the new parameter to maintain
existing behavior (MPTCP disabled by default)
Co-Developed-by: Gang Yan <yangang@kylinos.cn>
Signed-off-by: Gang Yan <yangang@kylinos.cn>
Signed-off-by: Geliang Tang <geliang@kernel.org>
---
src/java.base/share/classes/sun/nio/ch/Net.java | 6 +++---
src/java.base/unix/native/libnio/ch/Net.c | 5 +++--
src/java.base/windows/native/libnio/ch/Net.c | 2 +-
3 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/src/java.base/share/classes/sun/nio/ch/Net.java b/src/java.base/share/classes/sun/nio/ch/Net.java
index 9ec7975a35c..c086429380b 100644
--- a/src/java.base/share/classes/sun/nio/ch/Net.java
+++ b/src/java.base/share/classes/sun/nio/ch/Net.java
@@ -488,7 +488,7 @@ static FileDescriptor socket() throws IOException {
static FileDescriptor socket(ProtocolFamily family, boolean stream) throws IOException {
boolean preferIPv6 = isIPv6Available() &&
(family != StandardProtocolFamily.INET);
- return IOUtil.newFD(socket0(preferIPv6, stream, false, FAST_LOOPBACK));
+ return IOUtil.newFD(socket0(preferIPv6, stream, false, FAST_LOOPBACK, false));
}
static FileDescriptor serverSocket() {
@@ -498,12 +498,12 @@ static FileDescriptor serverSocket() {
static FileDescriptor serverSocket(ProtocolFamily family) {
boolean preferIPv6 = isIPv6Available() &&
(family != StandardProtocolFamily.INET);
- return IOUtil.newFD(socket0(preferIPv6, true, true, FAST_LOOPBACK));
+ return IOUtil.newFD(socket0(preferIPv6, true, true, FAST_LOOPBACK, false));
}
// Due to oddities SO_REUSEADDR on Windows reuse is ignored
private static native int socket0(boolean preferIPv6, boolean stream, boolean reuse,
- boolean fastLoopback);
+ boolean fastLoopback, boolean mptcp);
public static void bind(FileDescriptor fd, InetAddress addr, int port)
throws IOException
diff --git a/src/java.base/unix/native/libnio/ch/Net.c b/src/java.base/unix/native/libnio/ch/Net.c
index 28c1814f422..1b08539873f 100644
--- a/src/java.base/unix/native/libnio/ch/Net.c
+++ b/src/java.base/unix/native/libnio/ch/Net.c
@@ -255,13 +255,14 @@ Java_sun_nio_ch_Net_canUseIPv6OptionsWithIPv4LocalAddress0(JNIEnv* env, jclass c
JNIEXPORT jint JNICALL
Java_sun_nio_ch_Net_socket0(JNIEnv *env, jclass cl, jboolean preferIPv6,
- jboolean stream, jboolean reuse, jboolean ignored)
+ jboolean stream, jboolean reuse, jboolean ignored, jboolean mptcp)
{
int fd;
int type = (stream ? SOCK_STREAM : SOCK_DGRAM);
int domain = (ipv6_available() && preferIPv6) ? AF_INET6 : AF_INET;
+ int protocol = (stream && mptcp) ? IPPROTO_MPTCP : 0;
- fd = socket(domain, type, 0);
+ fd = socket(domain, type, protocol);
if (fd < 0) {
return handleSocketError(env, errno);
}
diff --git a/src/java.base/windows/native/libnio/ch/Net.c b/src/java.base/windows/native/libnio/ch/Net.c
index 814f502c48a..c563aa9f031 100644
--- a/src/java.base/windows/native/libnio/ch/Net.c
+++ b/src/java.base/windows/native/libnio/ch/Net.c
@@ -152,7 +152,7 @@ Java_sun_nio_ch_Net_canUseIPv6OptionsWithIPv4LocalAddress0(JNIEnv* env, jclass c
JNIEXPORT jint JNICALL
Java_sun_nio_ch_Net_socket0(JNIEnv *env, jclass cl, jboolean preferIPv6,
- jboolean stream, jboolean reuse, jboolean fastLoopback)
+ jboolean stream, jboolean reuse, jboolean fastLoopback, jboolean mptcp)
{
SOCKET s;
int domain = (preferIPv6) ? AF_INET6 : AF_INET;
--
2.48.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH mptcp-next 2/7] Add MPTCP server socket creation support
2025-07-23 5:16 [PATCH mptcp-next 0/7] Add MPTCP support to Java Networking API Geliang Tang
2025-07-23 5:16 ` [PATCH mptcp-next 1/7] Add MPTCP support for socket creation Geliang Tang
@ 2025-07-23 5:16 ` Geliang Tang
2025-07-30 22:04 ` Matthieu Baerts
2025-07-23 5:16 ` [PATCH mptcp-next 3/7] Add MPTCP client " Geliang Tang
` (5 subsequent siblings)
7 siblings, 1 reply; 16+ messages in thread
From: Geliang Tang @ 2025-07-23 5:16 UTC (permalink / raw)
To: mptcp; +Cc: Geliang Tang, Gang Yan
This patch introduces new methods to create server sockets with Multipath
TCP (MPTCP) support:
1. Added an overloaded 'serverSocket' method that accepts an 'mptcp'
parameter to enable MPTCP
2. Added a convenience method 'mptcpServerSocket()' for creating
MPTCP-enabled server sockets using the unspecified protocol family by
default
The changes maintain backward compatibility while providing explicit MPTCP
support for server socket creation. The new methods leverage the existing
socket0 infrastructure with the MPTCP flag added in the previous patch.
Co-Developed-by: Gang Yan <yangang@kylinos.cn>
Signed-off-by: Gang Yan <yangang@kylinos.cn>
Signed-off-by: Geliang Tang <geliang@kernel.org>
---
src/java.base/share/classes/sun/nio/ch/Net.java | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/src/java.base/share/classes/sun/nio/ch/Net.java b/src/java.base/share/classes/sun/nio/ch/Net.java
index c086429380b..aa3ed087d2c 100644
--- a/src/java.base/share/classes/sun/nio/ch/Net.java
+++ b/src/java.base/share/classes/sun/nio/ch/Net.java
@@ -501,6 +501,16 @@ static FileDescriptor serverSocket(ProtocolFamily family) {
return IOUtil.newFD(socket0(preferIPv6, true, true, FAST_LOOPBACK, false));
}
+ static FileDescriptor serverSocket(ProtocolFamily family, boolean mptcp) {
+ boolean preferIPv6 = isIPv6Available() &&
+ (family != StandardProtocolFamily.INET);
+ return IOUtil.newFD(socket0(preferIPv6, true, true, FAST_LOOPBACK, mptcp));
+ }
+
+ static FileDescriptor mptcpServerSocket() {
+ return serverSocket(UNSPEC, true);
+ }
+
// Due to oddities SO_REUSEADDR on Windows reuse is ignored
private static native int socket0(boolean preferIPv6, boolean stream, boolean reuse,
boolean fastLoopback, boolean mptcp);
--
2.48.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH mptcp-next 3/7] Add MPTCP client socket creation support
2025-07-23 5:16 [PATCH mptcp-next 0/7] Add MPTCP support to Java Networking API Geliang Tang
2025-07-23 5:16 ` [PATCH mptcp-next 1/7] Add MPTCP support for socket creation Geliang Tang
2025-07-23 5:16 ` [PATCH mptcp-next 2/7] Add MPTCP server socket creation support Geliang Tang
@ 2025-07-23 5:16 ` Geliang Tang
2025-07-23 5:16 ` [PATCH mptcp-next 4/7] Add MPTCP support to NioSocketImpl Geliang Tang
` (4 subsequent siblings)
7 siblings, 0 replies; 16+ messages in thread
From: Geliang Tang @ 2025-07-23 5:16 UTC (permalink / raw)
To: mptcp; +Cc: Geliang Tang, Gang Yan
This patch extends the socket creation API to support Multipath TCP
(MPTCP) for client sockets:
1. Added an overloaded 'socket' method that accepts an 'mptcp' parameter
to explicitly enable/disable MPTCP
2. Introduced a convenience method 'mptcpSocket()' for creating
MPTCP-enabled client sockets using the unspecified protocol family by
default
The changes maintain consistency with the existing socket API while
providing first-class support for MPTCP client sockets. The implementation
builds upon the foundation laid in previous patches, utilizing the socket0
infrastructure with MPTCP protocol support.
Co-Developed-by: Gang Yan <yangang@kylinos.cn>
Signed-off-by: Gang Yan <yangang@kylinos.cn>
Signed-off-by: Geliang Tang <geliang@kernel.org>
---
src/java.base/share/classes/sun/nio/ch/Net.java | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/src/java.base/share/classes/sun/nio/ch/Net.java b/src/java.base/share/classes/sun/nio/ch/Net.java
index aa3ed087d2c..cf5dbddc28c 100644
--- a/src/java.base/share/classes/sun/nio/ch/Net.java
+++ b/src/java.base/share/classes/sun/nio/ch/Net.java
@@ -491,6 +491,16 @@ static FileDescriptor socket(ProtocolFamily family, boolean stream) throws IOExc
return IOUtil.newFD(socket0(preferIPv6, stream, false, FAST_LOOPBACK, false));
}
+ static FileDescriptor socket(ProtocolFamily family, boolean stream, boolean mptcp) throws IOException {
+ boolean preferIPv6 = isIPv6Available() &&
+ (family != StandardProtocolFamily.INET);
+ return IOUtil.newFD(socket0(preferIPv6, stream, false, FAST_LOOPBACK, mptcp));
+ }
+
+ static FileDescriptor mptcpSocket() throws IOException {
+ return socket(UNSPEC, true, true);
+ }
+
static FileDescriptor serverSocket() {
return serverSocket(UNSPEC);
}
--
2.48.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH mptcp-next 4/7] Add MPTCP support to NioSocketImpl
2025-07-23 5:16 [PATCH mptcp-next 0/7] Add MPTCP support to Java Networking API Geliang Tang
` (2 preceding siblings ...)
2025-07-23 5:16 ` [PATCH mptcp-next 3/7] Add MPTCP client " Geliang Tang
@ 2025-07-23 5:16 ` Geliang Tang
2025-07-23 5:16 ` [PATCH mptcp-next 5/7] Add MPTCP support to ServerSocket class Geliang Tang
` (3 subsequent siblings)
7 siblings, 0 replies; 16+ messages in thread
From: Geliang Tang @ 2025-07-23 5:16 UTC (permalink / raw)
To: mptcp; +Cc: Geliang Tang, Gang Yan
This patch integrates MPTCP support into the core socket implementation
by:
1. Adding a new createPlatformSocketImpl factory method that accepts an
mptcp parameter
2. Extending NioSocketImpl to track MPTCP state with a new mptcp field
3. Modifying socket creation logic to use the appropriate MPTCP-enabled
methods:
- Uses Net.mptcpServerSocket() for server sockets when MPTCP is enabled
- Uses Net.mptcpSocket() for client sockets when MPTCP is enabled
The changes maintain backward compatibility while adding first-class MPTCP
support to the socket implementation layer. The implementation builds upon
the MPTCP infrastructure added in previous patches.
Co-Developed-by: Gang Yan <yangang@kylinos.cn>
Signed-off-by: Gang Yan <yangang@kylinos.cn>
Signed-off-by: Geliang Tang <geliang@kernel.org>
---
.../share/classes/java/net/SocketImpl.java | 8 ++++++++
.../classes/sun/nio/ch/NioSocketImpl.java | 19 +++++++++++++++++--
2 files changed, 25 insertions(+), 2 deletions(-)
diff --git a/src/java.base/share/classes/java/net/SocketImpl.java b/src/java.base/share/classes/java/net/SocketImpl.java
index 15c12457aac..9d07366350c 100644
--- a/src/java.base/share/classes/java/net/SocketImpl.java
+++ b/src/java.base/share/classes/java/net/SocketImpl.java
@@ -52,6 +52,14 @@ static <S extends SocketImpl & PlatformSocketImpl> S createPlatformSocketImpl(bo
return (S) new NioSocketImpl(server);
}
+ /**
+ * Creates an instance of platform's SocketImpl
+ */
+ @SuppressWarnings("unchecked")
+ static <S extends SocketImpl & PlatformSocketImpl> S createPlatformSocketImpl(boolean server, boolean mptcp) {
+ return (S) new NioSocketImpl(server, mptcp);
+ }
+
/**
* The file descriptor object for this socket.
*/
diff --git a/src/java.base/share/classes/sun/nio/ch/NioSocketImpl.java b/src/java.base/share/classes/sun/nio/ch/NioSocketImpl.java
index dd81b356738..cf95a4e466e 100644
--- a/src/java.base/share/classes/sun/nio/ch/NioSocketImpl.java
+++ b/src/java.base/share/classes/sun/nio/ch/NioSocketImpl.java
@@ -86,6 +86,9 @@ public final class NioSocketImpl extends SocketImpl implements PlatformSocketImp
// true if this is a SocketImpl for a ServerSocket
private final boolean server;
+ // true if this is a SocketImpl for a MptcpServerSocket
+ private final boolean mptcp;
+
// Lock held when reading (also used when accepting or connecting)
private final ReentrantLock readLock = new ReentrantLock();
@@ -131,6 +134,18 @@ public final class NioSocketImpl extends SocketImpl implements PlatformSocketImp
*/
public NioSocketImpl(boolean server) {
this.server = server;
+ this.mptcp = false;
+ }
+
+ /**
+ * @param mptcp enable MPTCP
+ *
+ * Creates an instance of this SocketImpl.
+ * @param server true if this is a SocketImpl for a ServerSocket
+ */
+ public NioSocketImpl(boolean server, boolean mptcp) {
+ this.server = server;
+ this.mptcp = mptcp;
}
/**
@@ -468,9 +483,9 @@ protected void create(boolean stream) throws IOException {
throw new IOException("Already created");
FileDescriptor fd;
if (server) {
- fd = Net.serverSocket();
+ fd = mptcp ? Net.mptcpServerSocket() : Net.serverSocket();
} else {
- fd = Net.socket();
+ fd = mptcp ? Net.mptcpSocket() : Net.socket();
}
Runnable closer = closerFor(fd);
this.fd = fd;
--
2.48.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH mptcp-next 5/7] Add MPTCP support to ServerSocket class
2025-07-23 5:16 [PATCH mptcp-next 0/7] Add MPTCP support to Java Networking API Geliang Tang
` (3 preceding siblings ...)
2025-07-23 5:16 ` [PATCH mptcp-next 4/7] Add MPTCP support to NioSocketImpl Geliang Tang
@ 2025-07-23 5:16 ` Geliang Tang
2025-07-30 22:05 ` Matthieu Baerts
2025-07-23 5:16 ` [PATCH mptcp-next 6/7] Add MPTCP support to Socket class Geliang Tang
` (2 subsequent siblings)
7 siblings, 1 reply; 16+ messages in thread
From: Geliang Tang @ 2025-07-23 5:16 UTC (permalink / raw)
To: mptcp; +Cc: Geliang Tang, Gang Yan
This patch extends ServerSocket to support Multipath TCP (MPTCP) by:
1. Adding a new constructor that accepts an mptcp parameter to enable
MPTCP
2. Introducing a new createImpl factory method that propagates the MPTCP
setting to the underlying socket implementation
3. Maintaining all existing functionality while adding MPTCP capabilities
The new constructor follows the same pattern as existing ServerSocket
constructors but adds the mptcp parameter to control protocol selection.
When enabled, the implementation uses the MPTCP-enabled socket creation
path established in previous patches.
Co-Developed-by: Gang Yan <yangang@kylinos.cn>
Signed-off-by: Gang Yan <yangang@kylinos.cn>
Signed-off-by: Geliang Tang <geliang@kernel.org>
---
.../share/classes/java/net/ServerSocket.java | 66 +++++++++++++++++++
1 file changed, 66 insertions(+)
diff --git a/src/java.base/share/classes/java/net/ServerSocket.java b/src/java.base/share/classes/java/net/ServerSocket.java
index 945693ef65e..ba07bc4d721 100644
--- a/src/java.base/share/classes/java/net/ServerSocket.java
+++ b/src/java.base/share/classes/java/net/ServerSocket.java
@@ -226,6 +226,57 @@ public ServerSocket(int port, int backlog, InetAddress bindAddr) throws IOExcept
}
}
+ /**
+ * Create a server using <i>mptcp</i> (Multipath TCP) or TCP protocol with
+ * the specified port, listen backlog, and local IP address to bind to.
+ * The <i>bindAddr</i> argument can be used on a multi-homed host for a
+ * ServerSocket that will only accept connect requests to one of its addresses.
+ * If <i>bindAddr</i> is null, it will default accepting
+ * connections on any/all local addresses.
+ * The port must be between 0 and 65535, inclusive.
+ * A port number of {@code 0} means that the port number is
+ * automatically allocated, typically from an ephemeral port range.
+ * This port number can then be retrieved by calling
+ * {@link #getLocalPort getLocalPort}.
+ *
+ * The {@code backlog} argument is the requested maximum number of
+ * pending connections on the socket. Its exact semantics are implementation
+ * specific. In particular, an implementation may impose a maximum length
+ * or may choose to ignore the parameter altogether. The value provided
+ * should be greater than {@code 0}. If it is less than or equal to
+ * {@code 0}, then an implementation specific default will be used.
+ *
+ * The {@code mptcp} argument is used to control whether to create a socket
+ * with MPTCP or TCP protocol.
+ *
+ * @param port the port number, or {@code 0} to use a port
+ * number that is automatically allocated.
+ * @param backlog requested maximum length of the queue of incoming
+ * connections.
+ * @param bindAddr the local InetAddress the server will bind to
+ * @param mptcp create a socket with MPTCP or TCP protocol.
+ *
+ * @throws IOException if an I/O error occurs when opening the socket.
+ * @throws IllegalArgumentException if the port parameter is outside
+ * the specified range of valid port values, which is between
+ * 0 and 65535, inclusive.
+ */
+ @SuppressWarnings("this-escape")
+ public ServerSocket(int port, int backlog, InetAddress bindAddr, boolean mptcp) throws IOException {
+ if (port < 0 || port > 0xFFFF)
+ throw new IllegalArgumentException("Port value out of range: " + port);
+ if (backlog < 1)
+ backlog = 50;
+
+ this.impl = createImpl(mptcp);
+ try {
+ bind(new InetSocketAddress(bindAddr, port), backlog);
+ } catch (IOException e) {
+ close();
+ throw e;
+ }
+ }
+
/**
* Create a SocketImpl for a server socket. The SocketImpl is created
* without an underlying socket.
@@ -239,6 +290,21 @@ private static SocketImpl createImpl() {
}
}
+ /**
+ * Create a SocketImpl for a server socket. The SocketImpl is created
+ * without an underlying socket.
+ *
+ * @param mptcp create a socket with MPTCP or TCP protocol.
+ */
+ private static SocketImpl createImpl(boolean mptcp) {
+ SocketImplFactory factory = ServerSocket.factory;
+ if (factory != null) {
+ return factory.createSocketImpl();
+ } else {
+ return SocketImpl.createPlatformSocketImpl(true, mptcp);
+ }
+ }
+
/**
* Returns the {@code SocketImpl} for this ServerSocket, creating the
* underlying socket if required.
--
2.48.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH mptcp-next 6/7] Add MPTCP support to Socket class
2025-07-23 5:16 [PATCH mptcp-next 0/7] Add MPTCP support to Java Networking API Geliang Tang
` (4 preceding siblings ...)
2025-07-23 5:16 ` [PATCH mptcp-next 5/7] Add MPTCP support to ServerSocket class Geliang Tang
@ 2025-07-23 5:16 ` Geliang Tang
2025-07-30 22:05 ` Matthieu Baerts
2025-07-23 5:16 ` [PATCH mptcp-next 7/7] Add test cases for MPTCP socket functionality Geliang Tang
2025-07-30 22:03 ` [PATCH mptcp-next 0/7] Add MPTCP support to Java Networking API Matthieu Baerts
7 siblings, 1 reply; 16+ messages in thread
From: Geliang Tang @ 2025-07-23 5:16 UTC (permalink / raw)
To: mptcp; +Cc: Geliang Tang, Gang Yan
This patch extends the Socket class to support Multipath TCP (MPTCP) by:
1. Adding a new constructor that accepts an mptcp parameter to enable MPTCP
2. Introducing a new private Socket constructor variant that handles MPTCP
connections
3. Adding a createImpl factory method that propagates the MPTCP setting
to the underlying socket implementation
4. Maintaining backward compatibility while adding MPTCP capabilities
The implementation ensures MPTCP support is properly integrated with:
- Address resolution
- Socket binding
- Connection establishment
- Error handling
When MPTCP is enabled, the socket uses the MPTCP-enabled creation path
established in previous patches, while maintaining all existing socket
functionality for non-MPTCP cases.
Co-Developed-by: Gang Yan <yangang@kylinos.cn>
Signed-off-by: Gang Yan <yangang@kylinos.cn>
Signed-off-by: Geliang Tang <geliang@kernel.org>
---
.../share/classes/java/net/Socket.java | 88 +++++++++++++++++++
1 file changed, 88 insertions(+)
diff --git a/src/java.base/share/classes/java/net/Socket.java b/src/java.base/share/classes/java/net/Socket.java
index 692c3395f78..fc7bd5b98c0 100644
--- a/src/java.base/share/classes/java/net/Socket.java
+++ b/src/java.base/share/classes/java/net/Socket.java
@@ -403,6 +403,39 @@ public Socket(String host, int port, boolean stream) throws IOException {
(SocketAddress) null, stream);
}
+ /**
+ * Creates a stream socket and connects it to the specified port
+ * number on the named host using Multipath TCP (MPTCP) or TCP
+ * protocol.
+ * <p>
+ * If the specified host is {@code null} it is the equivalent of
+ * specifying the address as
+ * {@link java.net.InetAddress#getByName InetAddress.getByName}{@code (null)}.
+ * In other words, it is equivalent to specifying an address of the
+ * loopback interface. </p>
+ * <p>
+ * If the application has specified a {@linkplain SocketImplFactory client
+ * socket implementation factory}, that factory's
+ * {@linkplain SocketImplFactory#createSocketImpl() createSocketImpl}
+ * method is called to create the actual socket implementation. Otherwise
+ * a system-default socket implementation is created.
+ *
+ * @param host the host name, or {@code null} for the loopback address.
+ * @param port the port number.
+ * @param stream must be true, false is not allowed.
+ * @param mptcp create a socket with MPTCP or TCP protocol.
+ * @throws IOException if an I/O error occurs when creating the socket.
+ * @throws IllegalArgumentException if the stream parameter is {@code false}
+ * or if the port parameter is outside the specified range of valid
+ * port values, which is between 0 and 65535, inclusive.
+ */
+ @SuppressWarnings("this-escape")
+ public Socket(String host, int port, boolean stream, boolean mptcp) throws IOException {
+ this(host != null ? new InetSocketAddress(host, port) :
+ new InetSocketAddress(InetAddress.getByName(null), port),
+ (SocketAddress) null, stream, mptcp);
+ }
+
/**
* Creates a socket and connects it to the specified port number at
* the specified IP address.
@@ -483,6 +516,61 @@ private static SocketImpl createImpl() {
}
}
+ /**
+ * Initialize a new Socket that is connected to the given remote address.
+ * The MPTCP or TCP protocol socket is optionally bound to a local address
+ * before connecting.
+ *
+ * @param address the remote address to connect to
+ * @param localAddr the local address to bind to, can be null
+ * @param stream true for a stream socket, false for a datagram socket
+ * @param mptcp create a socket with MPTCP or TCP protocol
+ */
+ private Socket(SocketAddress address, SocketAddress localAddr, boolean stream, boolean mptcp)
+ throws IOException
+ {
+ Objects.requireNonNull(address);
+ if (!stream) {
+ throw new IllegalArgumentException(
+ "Socket constructor does not support creation of datagram sockets");
+ }
+ assert address instanceof InetSocketAddress;
+
+ // create the SocketImpl and the underlying socket
+ SocketImpl impl = createImpl(mptcp);
+ impl.create(stream);
+
+ this.impl = impl;
+ this.state = SOCKET_CREATED;
+
+ try {
+ if (localAddr != null) {
+ bind(localAddr);
+ }
+ connect(address);
+ } catch (Throwable throwable) {
+ closeSuppressingExceptions(throwable);
+ throw throwable;
+ }
+ }
+
+ /**
+ * Create a new SocketImpl for a connecting/client socket. The SocketImpl
+ * is created without an underlying socket.
+ *
+ * @param mptcp create a socket with MPTCP or TCP protocol.
+ */
+ private static SocketImpl createImpl(boolean mptcp) {
+ SocketImplFactory factory = Socket.factory;
+ if (factory != null) {
+ return factory.createSocketImpl();
+ } else {
+ // create a SOCKS SocketImpl that delegates to a platform SocketImpl
+ SocketImpl delegate = SocketImpl.createPlatformSocketImpl(false, mptcp);
+ return new SocksSocketImpl(delegate);
+ }
+ }
+
/**
* Returns the {@code SocketImpl} for this Socket, creating it, and the
* underlying socket, if required.
--
2.48.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH mptcp-next 7/7] Add test cases for MPTCP socket functionality
2025-07-23 5:16 [PATCH mptcp-next 0/7] Add MPTCP support to Java Networking API Geliang Tang
` (5 preceding siblings ...)
2025-07-23 5:16 ` [PATCH mptcp-next 6/7] Add MPTCP support to Socket class Geliang Tang
@ 2025-07-23 5:16 ` Geliang Tang
2025-07-30 22:08 ` Matthieu Baerts
2025-07-30 22:03 ` [PATCH mptcp-next 0/7] Add MPTCP support to Java Networking API Matthieu Baerts
7 siblings, 1 reply; 16+ messages in thread
From: Geliang Tang @ 2025-07-23 5:16 UTC (permalink / raw)
To: mptcp; +Cc: Geliang Tang, Gang Yan
This patch introduces comprehensive test coverage for the newly added
MPTCP socket support by:
1. Adding MPTCPServer.java - A test server that:
- Creates an MPTCP-enabled ServerSocket
- Accepts client connections
- Echoes received messages back to clients
- Handles graceful shutdown
2. Adding MPTCPClient.java - A test client that:
- Connects to the MPTCP server
- Sends user input to server
- Displays server responses
- Supports graceful termination
The tests verify:
- Basic MPTCP socket creation and connection
- Bidirectional communication
- Proper stream handling
- Error conditions
- Clean resource management
Both test programs demonstrate the usage of the new MPTCP-enabled
constructors added in previous patches.
Co-Developed-by: Gang Yan <yangang@kylinos.cn>
Signed-off-by: Gang Yan <yangang@kylinos.cn>
Signed-off-by: Geliang Tang <geliang@kernel.org>
---
.../java/net/ServerSocket/MPTCPServer.java | 58 +++++++++++++++++
test/jdk/java/net/Socket/MPTCPClient.java | 62 +++++++++++++++++++
2 files changed, 120 insertions(+)
create mode 100644 test/jdk/java/net/ServerSocket/MPTCPServer.java
create mode 100644 test/jdk/java/net/Socket/MPTCPClient.java
diff --git a/test/jdk/java/net/ServerSocket/MPTCPServer.java b/test/jdk/java/net/ServerSocket/MPTCPServer.java
new file mode 100644
index 00000000000..a28e4963943
--- /dev/null
+++ b/test/jdk/java/net/ServerSocket/MPTCPServer.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code 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
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.io.*;
+import java.net.*;
+
+public class MPTCPServer {
+ public static void main(String[] args) {
+ final int PORT = 12345;
+
+ try (ServerSocket serverSocket = new ServerSocket(PORT, 50, null, true)) {
+ System.out.println("Server started, waiting for client connection ...");
+
+ Socket clientSocket = serverSocket.accept();
+ System.out.println("Client connected: " + clientSocket.getInetAddress());
+
+ BufferedReader in = new BufferedReader(
+ new InputStreamReader(clientSocket.getInputStream()));
+ PrintWriter out = new PrintWriter(
+ clientSocket.getOutputStream(), true);
+
+ String inputLine;
+ while ((inputLine = in.readLine()) != null) {
+ System.out.println("Received from client: " + inputLine);
+ out.println("Server response: " + inputLine);
+
+ if ("exit".equalsIgnoreCase(inputLine)) {
+ break;
+ }
+ }
+
+ clientSocket.close();
+ System.out.println("Connection closed");
+ } catch (IOException e) {
+ System.err.println("Server exception: " + e.getMessage());
+ }
+ }
+}
diff --git a/test/jdk/java/net/Socket/MPTCPClient.java b/test/jdk/java/net/Socket/MPTCPClient.java
new file mode 100644
index 00000000000..18d815c39e7
--- /dev/null
+++ b/test/jdk/java/net/Socket/MPTCPClient.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code 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
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.io.*;
+import java.net.*;
+
+public class MPTCPClient {
+ public static void main(String[] args) {
+ final String HOST = "localhost";
+ final int PORT = 12345;
+
+ try (Socket socket = new Socket(HOST, PORT, true, true)) {
+ System.out.println("Connected to server");
+
+ BufferedReader in = new BufferedReader(
+ new InputStreamReader(socket.getInputStream()));
+ PrintWriter out = new PrintWriter(
+ socket.getOutputStream(), true);
+
+ BufferedReader stdIn = new BufferedReader(
+ new InputStreamReader(System.in));
+
+ String userInput;
+ System.out.println("Enter message (type 'exit' to quit):");
+ while ((userInput = stdIn.readLine()) != null) {
+ out.println(userInput);
+
+ System.out.println("Server response: " + in.readLine());
+
+ if ("exit".equalsIgnoreCase(userInput)) {
+ break;
+ }
+ }
+
+ System.out.println("Connection closed");
+ } catch (UnknownHostException e) {
+ System.err.println("Host not found: " + HOST);
+ } catch (IOException e) {
+ System.err.println("Client I/O error: " + e.getMessage());
+ }
+ }
+}
--
2.48.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [PATCH mptcp-next 0/7] Add MPTCP support to Java Networking API
2025-07-23 5:16 [PATCH mptcp-next 0/7] Add MPTCP support to Java Networking API Geliang Tang
` (6 preceding siblings ...)
2025-07-23 5:16 ` [PATCH mptcp-next 7/7] Add test cases for MPTCP socket functionality Geliang Tang
@ 2025-07-30 22:03 ` Matthieu Baerts
2025-07-31 7:49 ` Geliang Tang
7 siblings, 1 reply; 16+ messages in thread
From: Matthieu Baerts @ 2025-07-30 22:03 UTC (permalink / raw)
To: Geliang Tang, mptcp
Hi Geliang,
On 23/07/2025 07:16, Geliang Tang wrote:
> The Multipath TCP (MPTCP) protocol (v1 / RFC 8684) has been added in
> the upstream Linux kernel since v5.6.
>
> This patch series introduces comprehensive Multipath TCP (MPTCP) support
> to the Java Networking API, enabling applications to leverage MPTCP's
> capabilities for improved reliability and throughput.
Thank you for having looked at that.
> The implementation provides:
> 1. Core infrastructure for MPTCP socket creation (Patch 1)
> 2. Server and client socket creation APIs (Patches 2-3)
> 3. Integration with NIO socket implementation (Patch 4)
> 4. High-level Socket and ServerSocket support (Patches 5-6)
> 5. Comprehensive test cases (Patch 7)
>
> Key features:
> - Backward compatible API extensions
> - Platform-independent implementation
> - Explicit MPTCP enablement through new constructors
> - Full integration with existing socket functionality
> - Test coverage for basic MPTCP operations
>
> The changes maintain all existing functionality while adding MPTCP
> capabilities. When MPTCP is not enabled or not supported by the system, the
> implementation gracefully falls back to regular TCP behavior.
I don't think it is the case: if the system doesn't support it, an error
will be returned.
If the other host doesn't support it or didn't request it, a fallback
will be done.
Also, don't hesitate to share a link to https://mptcp.dev to help
reviewers understanding what MPTCP is.
> This work enables Java applications to benefit from MPTCP's capabilities:
> - Seamless handover between network interfaces
> - Aggregated bandwidth from multiple paths
> - Improved resilience to network failures
>
> The implementation has been tested on Linux systems with MPTCP kernel
> support enabled.
>
> https://github.com/openjdk/jdk
I have a few comments, but I don't know the project, and I didn't code
in Java for a while. Then, feel free to send this version or an updated
one to the Java Net maintainers (not sure how, but I'm sure you will
figure out :) ). Do not hesitate to share the link here.
> Geliang Tang (7):
> Add MPTCP support for socket creation
> Add MPTCP server socket creation support
> Add MPTCP client socket creation support
> Add MPTCP support to NioSocketImpl
> Add MPTCP support to ServerSocket class
> Add MPTCP support to Socket class
> Add test cases for MPTCP socket functionality
>
> .../share/classes/java/net/ServerSocket.java | 66 ++++++++++++++
> .../share/classes/java/net/Socket.java | 88 +++++++++++++++++++
> .../share/classes/java/net/SocketImpl.java | 8 ++
> .../share/classes/sun/nio/ch/Net.java | 26 +++++-
> .../classes/sun/nio/ch/NioSocketImpl.java | 19 +++-
> src/java.base/unix/native/libnio/ch/Net.c | 5 +-
> src/java.base/windows/native/libnio/ch/Net.c | 2 +-
> .../java/net/ServerSocket/MPTCPServer.java | 58 ++++++++++++
> test/jdk/java/net/Socket/MPTCPClient.java | 62 +++++++++++++
> 9 files changed, 326 insertions(+), 8 deletions(-)
> create mode 100644 test/jdk/java/net/ServerSocket/MPTCPServer.java
> create mode 100644 test/jdk/java/net/Socket/MPTCPClient.java
>
Cheers,
Matt
--
Sponsored by the NGI0 Core fund.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH mptcp-next 1/7] Add MPTCP support for socket creation
2025-07-23 5:16 ` [PATCH mptcp-next 1/7] Add MPTCP support for socket creation Geliang Tang
@ 2025-07-30 22:03 ` Matthieu Baerts
0 siblings, 0 replies; 16+ messages in thread
From: Matthieu Baerts @ 2025-07-30 22:03 UTC (permalink / raw)
To: Geliang Tang, mptcp; +Cc: Gang Yan
Hi Geliang,
On 23/07/2025 07:16, Geliang Tang wrote:
> This patch extends the socket creation functionality to support Multipath
> TCP (MPTCP) by adding a new 'mptcp' parameter to the native socket0 method.
> When enabled, the socket will be created with the IPPROTO_MPTCP protocol
> for stream sockets.
>
> The changes include:
> 1. Added the 'mptcp' parameter to socket0 method declarations in Net.java
> 2. Modified the native implementations in both Unix and Windows Net.c files
> to handle the new parameter and set the appropriate protocol
> 3. Updated all call sites to pass 'false' for the new parameter to maintain
> existing behavior (MPTCP disabled by default)
>
> Co-Developed-by: Gang Yan <yangang@kylinos.cn>
> Signed-off-by: Gang Yan <yangang@kylinos.cn>
> Signed-off-by: Geliang Tang <geliang@kernel.org>
> ---
> src/java.base/share/classes/sun/nio/ch/Net.java | 6 +++---
> src/java.base/unix/native/libnio/ch/Net.c | 5 +++--
> src/java.base/windows/native/libnio/ch/Net.c | 2 +-
> 3 files changed, 7 insertions(+), 6 deletions(-)
>
> diff --git a/src/java.base/share/classes/sun/nio/ch/Net.java b/src/java.base/share/classes/sun/nio/ch/Net.java
> index 9ec7975a35c..c086429380b 100644
> --- a/src/java.base/share/classes/sun/nio/ch/Net.java
> +++ b/src/java.base/share/classes/sun/nio/ch/Net.java
> @@ -488,7 +488,7 @@ static FileDescriptor socket() throws IOException {
> static FileDescriptor socket(ProtocolFamily family, boolean stream) throws IOException {
> boolean preferIPv6 = isIPv6Available() &&
> (family != StandardProtocolFamily.INET);
> - return IOUtil.newFD(socket0(preferIPv6, stream, false, FAST_LOOPBACK));
> + return IOUtil.newFD(socket0(preferIPv6, stream, false, FAST_LOOPBACK, false));
> }
>
> static FileDescriptor serverSocket() {
> @@ -498,12 +498,12 @@ static FileDescriptor serverSocket() {
> static FileDescriptor serverSocket(ProtocolFamily family) {
> boolean preferIPv6 = isIPv6Available() &&
> (family != StandardProtocolFamily.INET);
> - return IOUtil.newFD(socket0(preferIPv6, true, true, FAST_LOOPBACK));
> + return IOUtil.newFD(socket0(preferIPv6, true, true, FAST_LOOPBACK, false));
> }
>
> // Due to oddities SO_REUSEADDR on Windows reuse is ignored
> private static native int socket0(boolean preferIPv6, boolean stream, boolean reuse,
> - boolean fastLoopback);
> + boolean fastLoopback, boolean mptcp);
>
> public static void bind(FileDescriptor fd, InetAddress addr, int port)
> throws IOException
> diff --git a/src/java.base/unix/native/libnio/ch/Net.c b/src/java.base/unix/native/libnio/ch/Net.c
> index 28c1814f422..1b08539873f 100644
> --- a/src/java.base/unix/native/libnio/ch/Net.c
> +++ b/src/java.base/unix/native/libnio/ch/Net.c
> @@ -255,13 +255,14 @@ Java_sun_nio_ch_Net_canUseIPv6OptionsWithIPv4LocalAddress0(JNIEnv* env, jclass c
>
> JNIEXPORT jint JNICALL
> Java_sun_nio_ch_Net_socket0(JNIEnv *env, jclass cl, jboolean preferIPv6,
> - jboolean stream, jboolean reuse, jboolean ignored)
> + jboolean stream, jboolean reuse, jboolean ignored, jboolean mptcp)
(I don't know if there is a limit for the number of chars per lines,
maybe you need to go to the next line?)
> {
> int fd;
> int type = (stream ? SOCK_STREAM : SOCK_DGRAM);
> int domain = (ipv6_available() && preferIPv6) ? AF_INET6 : AF_INET;
> + int protocol = (stream && mptcp) ? IPPROTO_MPTCP : 0;
I guess you will still need to check if IPPROTO_MPTCP is defined for old
systems, or the ones not using Linux. Something like that:
int protocol =
#ifdef IPPROTO_MPTCP
(stream && mptcp) ? IPPROTO_MPTCP :
#endif
0;
(or another style, I don't know what is usually being used here.)
>
> - fd = socket(domain, type, 0);
> + fd = socket(domain, type, protocol);
> if (fd < 0) {
> return handleSocketError(env, errno);
> }
> diff --git a/src/java.base/windows/native/libnio/ch/Net.c b/src/java.base/windows/native/libnio/ch/Net.c
> index 814f502c48a..c563aa9f031 100644
> --- a/src/java.base/windows/native/libnio/ch/Net.c
> +++ b/src/java.base/windows/native/libnio/ch/Net.c
> @@ -152,7 +152,7 @@ Java_sun_nio_ch_Net_canUseIPv6OptionsWithIPv4LocalAddress0(JNIEnv* env, jclass c
>
> JNIEXPORT jint JNICALL
> Java_sun_nio_ch_Net_socket0(JNIEnv *env, jclass cl, jboolean preferIPv6,
> - jboolean stream, jboolean reuse, jboolean fastLoopback)
> + jboolean stream, jboolean reuse, jboolean fastLoopback, jboolean mptcp)
> {
> SOCKET s;
> int domain = (preferIPv6) ? AF_INET6 : AF_INET;
Cheers,
Matt
--
Sponsored by the NGI0 Core fund.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH mptcp-next 2/7] Add MPTCP server socket creation support
2025-07-23 5:16 ` [PATCH mptcp-next 2/7] Add MPTCP server socket creation support Geliang Tang
@ 2025-07-30 22:04 ` Matthieu Baerts
0 siblings, 0 replies; 16+ messages in thread
From: Matthieu Baerts @ 2025-07-30 22:04 UTC (permalink / raw)
To: Geliang Tang, mptcp; +Cc: Gang Yan
Hi Geliang,
On 23/07/2025 07:16, Geliang Tang wrote:
> This patch introduces new methods to create server sockets with Multipath
> TCP (MPTCP) support:
>
> 1. Added an overloaded 'serverSocket' method that accepts an 'mptcp'
> parameter to enable MPTCP
> 2. Added a convenience method 'mptcpServerSocket()' for creating
> MPTCP-enabled server sockets using the unspecified protocol family by
> default
>
> The changes maintain backward compatibility while providing explicit MPTCP
> support for server socket creation. The new methods leverage the existing
> socket0 infrastructure with the MPTCP flag added in the previous patch.
>
> Co-Developed-by: Gang Yan <yangang@kylinos.cn>
> Signed-off-by: Gang Yan <yangang@kylinos.cn>
> Signed-off-by: Geliang Tang <geliang@kernel.org>
> ---
> src/java.base/share/classes/sun/nio/ch/Net.java | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
> diff --git a/src/java.base/share/classes/sun/nio/ch/Net.java b/src/java.base/share/classes/sun/nio/ch/Net.java
> index c086429380b..aa3ed087d2c 100644
> --- a/src/java.base/share/classes/sun/nio/ch/Net.java
> +++ b/src/java.base/share/classes/sun/nio/ch/Net.java
> @@ -501,6 +501,16 @@ static FileDescriptor serverSocket(ProtocolFamily family) {
> return IOUtil.newFD(socket0(preferIPv6, true, true, FAST_LOOPBACK, false));
> }
>
> + static FileDescriptor serverSocket(ProtocolFamily family, boolean mptcp) {
> + boolean preferIPv6 = isIPv6Available() &&
> + (family != StandardProtocolFamily.INET);
> + return IOUtil.newFD(socket0(preferIPv6, true, true, FAST_LOOPBACK, mptcp));
> + }
> +
> + static FileDescriptor mptcpServerSocket() {
I didn't check what is usually being done, but is this new helper really
needed? Is it not enough with the new serverSocket() extension?
Also, could you not have serverSocket(ProtocolFamily family) calling the
new serverSocket(family, false) instead of duplicating the code above?
> + return serverSocket(UNSPEC, true);
> + }
> +
> // Due to oddities SO_REUSEADDR on Windows reuse is ignored
> private static native int socket0(boolean preferIPv6, boolean stream, boolean reuse,
> boolean fastLoopback, boolean mptcp);
Cheers,
Matt
--
Sponsored by the NGI0 Core fund.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH mptcp-next 5/7] Add MPTCP support to ServerSocket class
2025-07-23 5:16 ` [PATCH mptcp-next 5/7] Add MPTCP support to ServerSocket class Geliang Tang
@ 2025-07-30 22:05 ` Matthieu Baerts
0 siblings, 0 replies; 16+ messages in thread
From: Matthieu Baerts @ 2025-07-30 22:05 UTC (permalink / raw)
To: Geliang Tang, mptcp; +Cc: Gang Yan
Hi Geliang,
On 23/07/2025 07:16, Geliang Tang wrote:
> This patch extends ServerSocket to support Multipath TCP (MPTCP) by:
>
> 1. Adding a new constructor that accepts an mptcp parameter to enable
> MPTCP
> 2. Introducing a new createImpl factory method that propagates the MPTCP
> setting to the underlying socket implementation
> 3. Maintaining all existing functionality while adding MPTCP capabilities
>
> The new constructor follows the same pattern as existing ServerSocket
> constructors but adds the mptcp parameter to control protocol selection.
> When enabled, the implementation uses the MPTCP-enabled socket creation
> path established in previous patches.
Similar to my comment in patch 2/7, I don't know what is best in this
project, but maybe instead of duplicating helpers, you could have the
previous helper calling the new extension?
So ServerSocket(int port, int backlog, InetAddress bindAddr) would call
the new one with 'mptcp' as new parameter? Same for createImpl()?
But not sure what the Java maintainers prefer. Maybe they are OK with
what you suggested.
Cheers,
Matt
--
Sponsored by the NGI0 Core fund.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH mptcp-next 6/7] Add MPTCP support to Socket class
2025-07-23 5:16 ` [PATCH mptcp-next 6/7] Add MPTCP support to Socket class Geliang Tang
@ 2025-07-30 22:05 ` Matthieu Baerts
0 siblings, 0 replies; 16+ messages in thread
From: Matthieu Baerts @ 2025-07-30 22:05 UTC (permalink / raw)
To: Geliang Tang, mptcp; +Cc: Gang Yan
Hi Geliang,
On 23/07/2025 07:16, Geliang Tang wrote:
> This patch extends the Socket class to support Multipath TCP (MPTCP) by:
>
> 1. Adding a new constructor that accepts an mptcp parameter to enable MPTCP
> 2. Introducing a new private Socket constructor variant that handles MPTCP
> connections
> 3. Adding a createImpl factory method that propagates the MPTCP setting
> to the underlying socket implementation
> 4. Maintaining backward compatibility while adding MPTCP capabilities
Same here: the new helper could be called from the existing Socket() one
instead of duplicating the code.
Cheers,
Matt
--
Sponsored by the NGI0 Core fund.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH mptcp-next 7/7] Add test cases for MPTCP socket functionality
2025-07-23 5:16 ` [PATCH mptcp-next 7/7] Add test cases for MPTCP socket functionality Geliang Tang
@ 2025-07-30 22:08 ` Matthieu Baerts
0 siblings, 0 replies; 16+ messages in thread
From: Matthieu Baerts @ 2025-07-30 22:08 UTC (permalink / raw)
To: Geliang Tang, mptcp; +Cc: Gang Yan
Hi Geliang,
On 23/07/2025 07:16, Geliang Tang wrote:
> This patch introduces comprehensive test coverage for the newly added
> MPTCP socket support by:
>
> 1. Adding MPTCPServer.java - A test server that:
> - Creates an MPTCP-enabled ServerSocket
> - Accepts client connections
> - Echoes received messages back to clients
> - Handles graceful shutdown
>
> 2. Adding MPTCPClient.java - A test client that:
> - Connects to the MPTCP server
> - Sends user input to server
> - Displays server responses
> - Supports graceful termination
>
> The tests verify:
> - Basic MPTCP socket creation and connection
> - Bidirectional communication
> - Proper stream handling
> - Error conditions
> - Clean resource management
>
> Both test programs demonstrate the usage of the new MPTCP-enabled
> constructors added in previous patches.
I don't know what is usually being done here, but these tests will not
be used by a CI I guess. Is it an issue?
If that's normal, no need to add something like a README to explain how
to test that?
Also, these tests don't check if MPTCP is being used, nor have pre-check
to see if the system supports MPTCP (otherwise the test will fail).
Cheers,
Matt
--
Sponsored by the NGI0 Core fund.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH mptcp-next 0/7] Add MPTCP support to Java Networking API
2025-07-30 22:03 ` [PATCH mptcp-next 0/7] Add MPTCP support to Java Networking API Matthieu Baerts
@ 2025-07-31 7:49 ` Geliang Tang
2025-07-31 9:33 ` Matthieu Baerts
0 siblings, 1 reply; 16+ messages in thread
From: Geliang Tang @ 2025-07-31 7:49 UTC (permalink / raw)
To: Matthieu Baerts, mptcp
Hi Matt,
On Thu, 2025-07-31 at 00:03 +0200, Matthieu Baerts wrote:
> Hi Geliang,
>
> On 23/07/2025 07:16, Geliang Tang wrote:
> > The Multipath TCP (MPTCP) protocol (v1 / RFC 8684) has been added
> > in
> > the upstream Linux kernel since v5.6.
> >
> > This patch series introduces comprehensive Multipath TCP (MPTCP)
> > support
> > to the Java Networking API, enabling applications to leverage
> > MPTCP's
> > capabilities for improved reliability and throughput.
>
> Thank you for having looked at that.
>
> > The implementation provides:
> > 1. Core infrastructure for MPTCP socket creation (Patch 1)
> > 2. Server and client socket creation APIs (Patches 2-3)
> > 3. Integration with NIO socket implementation (Patch 4)
> > 4. High-level Socket and ServerSocket support (Patches 5-6)
> > 5. Comprehensive test cases (Patch 7)
> >
> > Key features:
> > - Backward compatible API extensions
> > - Platform-independent implementation
> > - Explicit MPTCP enablement through new constructors
> > - Full integration with existing socket functionality
> > - Test coverage for basic MPTCP operations
> >
> > The changes maintain all existing functionality while adding MPTCP
> > capabilities. When MPTCP is not enabled or not supported by the
> > system, the
> > implementation gracefully falls back to regular TCP behavior.
>
> I don't think it is the case: if the system doesn't support it, an
> error
> will be returned.
>
> If the other host doesn't support it or didn't request it, a fallback
> will be done.
>
> Also, don't hesitate to share a link to https://mptcp.dev to help
> reviewers understanding what MPTCP is.
>
> > This work enables Java applications to benefit from MPTCP's
> > capabilities:
> > - Seamless handover between network interfaces
> > - Aggregated bandwidth from multiple paths
> > - Improved resilience to network failures
> >
> > The implementation has been tested on Linux systems with MPTCP
> > kernel
> > support enabled.
> >
> > https://github.com/openjdk/jdk
> I have a few comments, but I don't know the project, and I didn't
> code
> in Java for a while. Then, feel free to send this version or an
> updated
> one to the Java Net maintainers (not sure how, but I'm sure you will
> figure out :) ). Do not hesitate to share the link here.
How about I submit a pull request to openjdk?
>
> > Geliang Tang (7):
> > Add MPTCP support for socket creation
> > Add MPTCP server socket creation support
> > Add MPTCP client socket creation support
> > Add MPTCP support to NioSocketImpl
> > Add MPTCP support to ServerSocket class
> > Add MPTCP support to Socket class
> > Add test cases for MPTCP socket functionality
> >
> > .../share/classes/java/net/ServerSocket.java | 66 ++++++++++++++
> > .../share/classes/java/net/Socket.java | 88
> > +++++++++++++++++++
> > .../share/classes/java/net/SocketImpl.java | 8 ++
> > .../share/classes/sun/nio/ch/Net.java | 26 +++++-
> > .../classes/sun/nio/ch/NioSocketImpl.java | 19 +++-
> > src/java.base/unix/native/libnio/ch/Net.c | 5 +-
> > src/java.base/windows/native/libnio/ch/Net.c | 2 +-
> > .../java/net/ServerSocket/MPTCPServer.java | 58 ++++++++++++
> > test/jdk/java/net/Socket/MPTCPClient.java | 62 +++++++++++++
> > 9 files changed, 326 insertions(+), 8 deletions(-)
> > create mode 100644 test/jdk/java/net/ServerSocket/MPTCPServer.java
> > create mode 100644 test/jdk/java/net/Socket/MPTCPClient.java
> >
>
> Cheers,
> Matt
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH mptcp-next 0/7] Add MPTCP support to Java Networking API
2025-07-31 7:49 ` Geliang Tang
@ 2025-07-31 9:33 ` Matthieu Baerts
0 siblings, 0 replies; 16+ messages in thread
From: Matthieu Baerts @ 2025-07-31 9:33 UTC (permalink / raw)
To: Geliang Tang; +Cc: mptcp
Hi Geliang,
On 31/07/2025 09:49, Geliang Tang wrote:
> Hi Matt,
>
> On Thu, 2025-07-31 at 00:03 +0200, Matthieu Baerts wrote:
>> Hi Geliang,
>>
>> On 23/07/2025 07:16, Geliang Tang wrote:
>>> The Multipath TCP (MPTCP) protocol (v1 / RFC 8684) has been added
>>> in
>>> the upstream Linux kernel since v5.6.
>>>
>>> This patch series introduces comprehensive Multipath TCP (MPTCP)
>>> support
>>> to the Java Networking API, enabling applications to leverage
>>> MPTCP's
>>> capabilities for improved reliability and throughput.
>>
>> Thank you for having looked at that.
>>
>>> The implementation provides:
>>> 1. Core infrastructure for MPTCP socket creation (Patch 1)
>>> 2. Server and client socket creation APIs (Patches 2-3)
>>> 3. Integration with NIO socket implementation (Patch 4)
>>> 4. High-level Socket and ServerSocket support (Patches 5-6)
>>> 5. Comprehensive test cases (Patch 7)
>>>
>>> Key features:
>>> - Backward compatible API extensions
>>> - Platform-independent implementation
>>> - Explicit MPTCP enablement through new constructors
>>> - Full integration with existing socket functionality
>>> - Test coverage for basic MPTCP operations
>>>
>>> The changes maintain all existing functionality while adding MPTCP
>>> capabilities. When MPTCP is not enabled or not supported by the
>>> system, the
>>> implementation gracefully falls back to regular TCP behavior.
>>
>> I don't think it is the case: if the system doesn't support it, an
>> error
>> will be returned.
>>
>> If the other host doesn't support it or didn't request it, a fallback
>> will be done.
>>
>> Also, don't hesitate to share a link to https://mptcp.dev to help
>> reviewers understanding what MPTCP is.
>>
>>> This work enables Java applications to benefit from MPTCP's
>>> capabilities:
>>> - Seamless handover between network interfaces
>>> - Aggregated bandwidth from multiple paths
>>> - Improved resilience to network failures
>>>
>>> The implementation has been tested on Linux systems with MPTCP
>>> kernel
>>> support enabled.
>>>
>>> https://github.com/openjdk/jdk
>> I have a few comments, but I don't know the project, and I didn't
>> code
>> in Java for a while. Then, feel free to send this version or an
>> updated
>> one to the Java Net maintainers (not sure how, but I'm sure you will
>> figure out :) ). Do not hesitate to share the link here.
>
> How about I submit a pull request to openjdk?
I don't think that is that simple... Apparently you need to sign the
OCA, create a bug report, then later on, send a PR:
https://openjdk.org/guide/#i-have-a-patch-what-do-i-do
Not that easy to contribute...
Cheers,
Matt
--
Sponsored by the NGI0 Core fund.
^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2025-07-31 9:33 UTC | newest]
Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-23 5:16 [PATCH mptcp-next 0/7] Add MPTCP support to Java Networking API Geliang Tang
2025-07-23 5:16 ` [PATCH mptcp-next 1/7] Add MPTCP support for socket creation Geliang Tang
2025-07-30 22:03 ` Matthieu Baerts
2025-07-23 5:16 ` [PATCH mptcp-next 2/7] Add MPTCP server socket creation support Geliang Tang
2025-07-30 22:04 ` Matthieu Baerts
2025-07-23 5:16 ` [PATCH mptcp-next 3/7] Add MPTCP client " Geliang Tang
2025-07-23 5:16 ` [PATCH mptcp-next 4/7] Add MPTCP support to NioSocketImpl Geliang Tang
2025-07-23 5:16 ` [PATCH mptcp-next 5/7] Add MPTCP support to ServerSocket class Geliang Tang
2025-07-30 22:05 ` Matthieu Baerts
2025-07-23 5:16 ` [PATCH mptcp-next 6/7] Add MPTCP support to Socket class Geliang Tang
2025-07-30 22:05 ` Matthieu Baerts
2025-07-23 5:16 ` [PATCH mptcp-next 7/7] Add test cases for MPTCP socket functionality Geliang Tang
2025-07-30 22:08 ` Matthieu Baerts
2025-07-30 22:03 ` [PATCH mptcp-next 0/7] Add MPTCP support to Java Networking API Matthieu Baerts
2025-07-31 7:49 ` Geliang Tang
2025-07-31 9:33 ` Matthieu Baerts
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).