From nobody Wed Sep 17 18:02:55 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7D8192F4A for ; Wed, 23 Jul 2025 05:16:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753247793; cv=none; b=djACq54BiP5sE46fGTdIgL0B4PozR2S7k3iPs0NcpgbrjNLgR/w5x6EufxVTgt7tJnCgZwO/QSZPaPKJrOp4VySVMXZqCKyOz0a/zUKwGKIW5il06eVAkJ3DOJiyXHPSHDRon7OmyyivJp7vfzVRw4haHcU/Nbo/vyBMsyq9RPo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753247793; c=relaxed/simple; bh=yFFdsAFimvo32xUf0z6klzZnfpqJJGMUgrm9ftdg3yA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JwxYi2hBwUPkQLlQfz1UzWTcg4ZCS6pUPcWT1WXlIJGXONnpjJB1OLZucG34FqamDi95BayVRziVKaGuf0tkJuYaHHbZZN5pR/WNTzzpQn1YeWbZnbIMbY9sqYF40UXhlfSEn0D4/r6PaYSlouicqVQpaStla54a96PNpP5b3IE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ewP7tfxB; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ewP7tfxB" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B67C3C4CEE7; Wed, 23 Jul 2025 05:16:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1753247793; bh=yFFdsAFimvo32xUf0z6klzZnfpqJJGMUgrm9ftdg3yA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ewP7tfxBJ3SKMJeTQYhscX8Ab9K8Nm6lkSD3YpfoJHIChmmproT6zgLVVuJ8lkv2p EaiWGVCvNG8JKi8I3G1K7tg4db+dPBL2AMkVF+OnKsnIjpHTR3HHa5PoyOCLY9PTQf 5+jHpFm9fxv5BdHoq+MmyswD82ocAf220+RzByZa8uY4Mg6E4Ar8T1wGmjENQc4Yz/ XhcDcs4pT14EhOTNR3ix7SaH3X/gAZeyxDZ7udb2yGYCWgtRsVVK+H/4LQT3w7EQ8Y iVJ+mBG961HGyvQ/wAiVVlTBpZ8NApReApby+5P/rhVTv3ANyNn8ZwF7XFC0d0Z2bY NP7JKhbrEHnTw== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang , Gang Yan Subject: [PATCH mptcp-next 1/7] Add MPTCP support for socket creation Date: Wed, 23 Jul 2025 13:16:13 +0800 Message-ID: X-Mailer: git-send-email 2.48.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 Signed-off-by: Gang Yan Signed-off-by: Geliang Tang --- 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.bas= e/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) th= rows IOException { boolean preferIPv6 =3D isIPv6Available() && (family !=3D StandardProtocolFamily.INET); - return IOUtil.newFD(socket0(preferIPv6, stream, false, FAST_LOOPBA= CK)); + return IOUtil.newFD(socket0(preferIPv6, stream, false, FAST_LOOPBA= CK, false)); } =20 static FileDescriptor serverSocket() { @@ -498,12 +498,12 @@ static FileDescriptor serverSocket() { static FileDescriptor serverSocket(ProtocolFamily family) { boolean preferIPv6 =3D isIPv6Available() && (family !=3D StandardProtocolFamily.INET); - return IOUtil.newFD(socket0(preferIPv6, true, true, FAST_LOOPBACK)= ); + return IOUtil.newFD(socket0(preferIPv6, true, true, FAST_LOOPBACK,= false)); } =20 // 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); =20 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_canUseIPv6OptionsWithIPv4LocalAdd= ress0(JNIEnv* env, jclass c =20 JNIEXPORT jint JNICALL Java_sun_nio_ch_Net_socket0(JNIEnv *env, jclass cl, jboolean preferIPv6, - jboolean stream, jboolean reuse, jboolean igno= red) + jboolean stream, jboolean reuse, jboolean igno= red, jboolean mptcp) { int fd; int type =3D (stream ? SOCK_STREAM : SOCK_DGRAM); int domain =3D (ipv6_available() && preferIPv6) ? AF_INET6 : AF_INET; + int protocol =3D (stream && mptcp) ? IPPROTO_MPTCP : 0; =20 - fd =3D socket(domain, type, 0); + fd =3D 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/w= indows/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_canUseIPv6OptionsWithIPv4LocalAddre= ss0(JNIEnv* env, jclass c =20 JNIEXPORT jint JNICALL Java_sun_nio_ch_Net_socket0(JNIEnv *env, jclass cl, jboolean preferIPv6, - jboolean stream, jboolean reuse, jboolean fast= Loopback) + jboolean stream, jboolean reuse, jboolean fast= Loopback, jboolean mptcp) { SOCKET s; int domain =3D (preferIPv6) ? AF_INET6 : AF_INET; --=20 2.48.1 From nobody Wed Sep 17 18:02:55 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A4A785A79B for ; Wed, 23 Jul 2025 05:16:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753247795; cv=none; b=PMjDN2blf11IKXqrEpqGEG2rzchzQoQqUoN3jl8589Zzm5bYd1qj1o6INnYm3k8ysGwW3xWiZolCmfGsH6bQUWiksFH7QX0kGUpFSRYuo3Sn4iyY1SeAvtM+BOYSwmKlo7hVpSe5pA0jBwILYYg8navx3Rh2SxWSxduAiRONPUI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753247795; c=relaxed/simple; bh=xc9U11UBnbeSI6fbUP2/mZN476PSQJQAPSySV5iS3uE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pni/iylHqjutXTjxjcxAKyF2gWZhj6Wr+iXtorhFpE23oBfhQAyVBBvHpnzB5XGTZzQY9bTHUfw/H1UJxa0Jk2DmBq1QzafLkIf8vEb/uN/oJSiMTktSIQz7eFc+fai024qHkx9NiN30aRAq8MAq3k/PZ0LOQaVzuWeb/Vfl7t0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=scWBUh5r; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="scWBUh5r" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B483BC4CEE7; Wed, 23 Jul 2025 05:16:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1753247795; bh=xc9U11UBnbeSI6fbUP2/mZN476PSQJQAPSySV5iS3uE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=scWBUh5rPn0nqcNev4lTUUch+IPeRLiH5YEikjFM5MnYmUD9MSJZdV0ZuNadDVz2N G21AYKpMJSLsVy/OW1p8J9Wr1SRTSB+5Y/4WJY8xfVyyCj1g70rynQ9jEszGRqBu0Z ryqYJv/J0a4eTmnXPyBeo5+t2wccUdR1/6hURKE55mPoY44l14BKioLC7kkGPeEeck PYDWw9wedjcLlZh6vH9OfH66K5DBN/Q/Qp7q/YoLikbVJpW1YpkkmO9QHycd6eFl3y qYcEgVSPFShLb8ak7TMkCjXghxrJg62QRqDnUcDRYGkUjhp32vPkrK2et59i60XdKW YV3WpyWl+iOyA== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang , Gang Yan Subject: [PATCH mptcp-next 2/7] Add MPTCP server socket creation support Date: Wed, 23 Jul 2025 13:16:14 +0800 Message-ID: <931ce3edf07175a81607cfb0c00319c262462bc5.1753247666.git.geliang@kernel.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 Signed-off-by: Gang Yan Signed-off-by: Geliang Tang --- 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.bas= e/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 fami= ly) { return IOUtil.newFD(socket0(preferIPv6, true, true, FAST_LOOPBACK,= false)); } =20 + static FileDescriptor serverSocket(ProtocolFamily family, boolean mptc= p) { + boolean preferIPv6 =3D isIPv6Available() && + (family !=3D 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); --=20 2.48.1 From nobody Wed Sep 17 18:02:55 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9A4882F4A for ; Wed, 23 Jul 2025 05:16:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753247799; cv=none; b=A39YkR2n12+i7dLXmP4s7mk/BX/ZAGcfxuShQwQPqGcCCy+jJbXEzC2tZD+gixLMLoXKxRa+HuN95CAt57pJj4/XvopEMUrvDtFk+lIV9gfRA0Dr5uE07zDwvIdFJmZES8IE1KpLLtvD94xTm3RX8H2Zqpi4knnpbqBBw7pAEEc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753247799; c=relaxed/simple; bh=HKBdxFHd2Fnzdh7om7SCDsCnykJO+LhNS3bPVDbG4dU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dR5KcBHLarPNuaEp5UgfZ50NMXAAw5QfbQ+C3ux4FKpy/J44755ZddDefqJUsO1G9yA1eocdbHJzPn0pkb8ttIU9emTW81gvSgTJibAnHLXiElSu/E4engcZ0qIBDv4psE8KqM34GyxzIg9XVUCsYojqgdO790ZtZOsYXOxY0Rg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=PklEBof3; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="PklEBof3" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 280BBC4CEE7; Wed, 23 Jul 2025 05:16:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1753247798; bh=HKBdxFHd2Fnzdh7om7SCDsCnykJO+LhNS3bPVDbG4dU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PklEBof3iGvG2I4EQJBCuB9M8qE/pyrO9kzVY49KtOVe7K0DYzve0vTII7knw7ytj 8dhQcpWyCwndkgD0WVOsgnfgIplNGA88wMzAHjVlhUcuyG6rtZHJ6g/EFc2J8VPqjc fydpbYuest7Hxy7suVjZ9a3gvOMyaD8kU32w99hQmuGP+zVzxRTkVWIBOO4APN9yF0 txQt5JBpCHE5cQw0QwQy26UJtuEYti1O2Ivl79Ko3Fz/APnuWK6xAj4fs9j3DVXgRq cYhVG2SGeAfea+revGkKvq9WJEdLPMIbjohvyv7UCBN6/eq3/Z94IfvRRzlY92yKQx NTmm6IcW7Bc5w== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang , Gang Yan Subject: [PATCH mptcp-next 3/7] Add MPTCP client socket creation support Date: Wed, 23 Jul 2025 13:16:15 +0800 Message-ID: X-Mailer: git-send-email 2.48.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 Signed-off-by: Gang Yan Signed-off-by: Geliang Tang --- 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.bas= e/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, bo= olean stream) throws IOExc return IOUtil.newFD(socket0(preferIPv6, stream, false, FAST_LOOPBA= CK, false)); } =20 + static FileDescriptor socket(ProtocolFamily family, boolean stream, bo= olean mptcp) throws IOException { + boolean preferIPv6 =3D isIPv6Available() && + (family !=3D StandardProtocolFamily.INET); + return IOUtil.newFD(socket0(preferIPv6, stream, false, FAST_LOOPBA= CK, mptcp)); + } + + static FileDescriptor mptcpSocket() throws IOException { + return socket(UNSPEC, true, true); + } + static FileDescriptor serverSocket() { return serverSocket(UNSPEC); } --=20 2.48.1 From nobody Wed Sep 17 18:02:55 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 568C52F4A for ; Wed, 23 Jul 2025 05:16:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753247809; cv=none; b=m2GN1Lyd4iota8BFNoh0m2jUOV3oZ8V41Dhu/oHaznCgU7NlN7i6X8rfCurZenCWOkhv0odZZJJSrkX2AhrQCIPvlJGqj3ppCU+7ghg66S2aIO9p+i00zn7OsueM0uoKz/iGR5fho5q2ikCklnUwNDr/1nYHMmdfKY+i4dlyKr4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753247809; c=relaxed/simple; bh=1QKrxnh5mU272uXKqZRtN/w8HziJDQ5gzYI62h1gj0I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lCmFU7eaXhoUxR1N+sIP3+5VOBGHn2jLoPbNWh6IP9z164XDFrFZR+8AH2ixzcQSPD0Sr8LfdArmfePLxfNjVwWWShVJabBEypyPxBQGK/34F8VzEXyG+uikJyyNXoKSPuZsQ3xTxoYvyJkKtPcR2A2dE4v8/D67vrZze27W0eU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=eTnsbo3S; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="eTnsbo3S" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CB170C4CEF4; Wed, 23 Jul 2025 05:16:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1753247808; bh=1QKrxnh5mU272uXKqZRtN/w8HziJDQ5gzYI62h1gj0I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eTnsbo3S9BHuEGBk5VR2pWimYs/ywq2kOWx2AcVtnXMpfGvITyMUeW4Qg0mlTdSL/ nbPV6/2suZvDgba2PJDNAVDtJUdsasiAm7/BLdiTj5hDXXjIhfEXV1spLmGA8Nudc7 hiAsWa+/cQ0k29Lw4xBJMcrJyzJuqqUF/X5b1KYjrLVQ5tfIU7DInH1Cr1BfupCo2f S6ZyQYA1/0TNbt946VmqKHFuUuprRIp7zZtuIBw4OxUvgyoJYlAu6qVqjiGSqRGsPo wodnsAlHGAHD3/w6RsZFB2KU6665ZycINqvax/QlbQ/6RyiLwgYky+GHfXloOWpEMd pn07oSx4CGjWg== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang , Gang Yan Subject: [PATCH mptcp-next 4/7] Add MPTCP support to NioSocketImpl Date: Wed, 23 Jul 2025 13:16:16 +0800 Message-ID: <3f213a7f6a1508108638ecc814314c156e0e0019.1753247666.git.geliang@kernel.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 Signed-off-by: Gang Yan Signed-off-by: Geliang Tang --- .../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/jav= a.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 cre= atePlatformSocketImpl(bo return (S) new NioSocketImpl(server); } =20 + /** + * Creates an instance of platform's SocketImpl + */ + @SuppressWarnings("unchecked") + static S createPlatformSoc= ketImpl(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/sr= c/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 imple= ments PlatformSocketImp // true if this is a SocketImpl for a ServerSocket private final boolean server; =20 + // 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 =3D new ReentrantLock(); =20 @@ -131,6 +134,18 @@ public final class NioSocketImpl extends SocketImpl im= plements PlatformSocketImp */ public NioSocketImpl(boolean server) { this.server =3D server; + this.mptcp =3D 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 =3D server; + this.mptcp =3D mptcp; } =20 /** @@ -468,9 +483,9 @@ protected void create(boolean stream) throws IOExceptio= n { throw new IOException("Already created"); FileDescriptor fd; if (server) { - fd =3D Net.serverSocket(); + fd =3D mptcp ? Net.mptcpServerSocket() : Net.serverSocket(= ); } else { - fd =3D Net.socket(); + fd =3D mptcp ? Net.mptcpSocket() : Net.socket(); } Runnable closer =3D closerFor(fd); this.fd =3D fd; --=20 2.48.1 From nobody Wed Sep 17 18:02:55 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F40842F4A for ; Wed, 23 Jul 2025 05:16:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753247813; cv=none; b=r9uatwQWMREIGJSsz5ilM5f/k/1skjQd8NcixKZgXVmRk5NI3uIJVwtEn1vlY2FLrVQxYXGty3/Nrz8Wkfg3aMUVSJS0GD/JKv/YSOJtFITyeOyx1imo4AcqarjPNPRdhA1FYoL4BCUDHsN9h0b0SfSN3AZy7i2EPlI9+nXp4C0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753247813; c=relaxed/simple; bh=ob13skpAWkNt5WiJ2tvEnnhPeYn0L51oo4IUCMIXwkw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=STc2zMJzzRz8dbPDjA9G77J4ZQVZIbnAGEODaRHShoX5oOV+lXV6THOENVlihb1pqABR/i21GLTGvG4mVVS9W3UF0l1f8zcLfXi6fLKJoF8kxU3rQqwr79QzJAYxzi2PECMeQIzHvY7+SUPRoZeYF1WckA0BaiWs07ap4YpRsGk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=GxUCuHwT; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="GxUCuHwT" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C4765C4CEF4; Wed, 23 Jul 2025 05:16:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1753247812; bh=ob13skpAWkNt5WiJ2tvEnnhPeYn0L51oo4IUCMIXwkw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GxUCuHwTYci15Wb3DF6D3Gqb+8bLBaOof8RjBl2losaxRuODcEiL51pwYg5iMFVWb K2rIJ4RnKQEQf4Sb7Jyw0R82BDM8viV1GKleBU7Nvl8JEe51OJT702VQjiFw0PJWYJ 2P33VXZDzP/tI8H7sn4r1wGNAiQ5LPTGaI7cELbej9g9js5jDITRLoAcPEHU4wF8nv jZYnIQD1qQW6mqPVN5dfHxJ9BZY3mwOw1zdwFjMS5tObl7OwiYErHACt95HWKnp+li +lCug4IafD5RntwMPt1Gl2CT33hnj0xN52SxR9Ho5P81VSGSLa4+au32Yl0QIrFrrs REY75+wYQAkrw== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang , Gang Yan Subject: [PATCH mptcp-next 5/7] Add MPTCP support to ServerSocket class Date: Wed, 23 Jul 2025 13:16:17 +0800 Message-ID: X-Mailer: git-send-email 2.48.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 Signed-off-by: Gang Yan Signed-off-by: Geliang Tang --- .../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/j= ava.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 } } =20 + /** + * Create a server using mptcp (Multipath TCP) or TCP protocol = with + * the specified port, listen backlog, and local IP address to bind to. + * The bindAddr argument can be used on a multi-homed host for a + * ServerSocket that will only accept connect requests to one of its a= ddresses. + * If bindAddr 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 implemen= tation + * specific. In particular, an implementation may impose a maximum len= gth + * 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 s= ocket + * 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 outsi= de + * the specified range of valid port values, which is betw= een + * 0 and 65535, inclusive. + */ + @SuppressWarnings("this-escape") + public ServerSocket(int port, int backlog, InetAddress bindAddr, boole= an mptcp) throws IOException { + if (port < 0 || port > 0xFFFF) + throw new IllegalArgumentException("Port value out of range: "= + port); + if (backlog < 1) + backlog =3D 50; + + this.impl =3D 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() { } } =20 + /** + * 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 =3D ServerSocket.factory; + if (factory !=3D null) { + return factory.createSocketImpl(); + } else { + return SocketImpl.createPlatformSocketImpl(true, mptcp); + } + } + /** * Returns the {@code SocketImpl} for this ServerSocket, creating the * underlying socket if required. --=20 2.48.1 From nobody Wed Sep 17 18:02:55 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 973042F4A for ; Wed, 23 Jul 2025 05:16:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753247815; cv=none; b=HKc7nGSki//B9Z95S46hMPrvnm5E/RsoYhCHCsWyz+bWdP9JrQqXZsOCv+LEjYnAWciuJiwIp5Ifq8LEwn2oyCJHtG5i2kAzEcK5qAZSv/vFypeQ2BjZOvTt8E2z2vn87kq3l/9yqiV+kzK6+6n6w6tu7MmffgYJIYJNxi12hYA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753247815; c=relaxed/simple; bh=gGcQsA8s1mzj17IIURPrilfJDY/qqL/XDJC5Urxcngg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=j3ZFT3ujK8K4p2d/s0D9/qmjdWFwKI3N8Y0TMSD74Aum7BPi2wKTgfrZs+J+eHfbWCwapUxubI1S4JKERPp2vwTJZrzFdKxNKJ0w22RGCK63jWvbj1nx8A6MkcBZ+5AmVD/OUANAqZzerTK/qnLB0TOYJLwcwkexND4gVux+pBs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=iXmyqjmA; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="iXmyqjmA" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3C960C4CEE7; Wed, 23 Jul 2025 05:16:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1753247815; bh=gGcQsA8s1mzj17IIURPrilfJDY/qqL/XDJC5Urxcngg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iXmyqjmAoeazriOm3P2f8kKPGPsF/PZ8LucBsqsdxpjGnXego5UP0gcmmqT8iGBmN WQyE+s/h1MgGJuM+o9H0BAUMH9jJryLvsugCLDrM/uWwtZRvm6ydKNAqYntoeaAC7i 04C0R+Eo2VImeYebgg3+7Vq+eaYScFZJ91OcBVrOSFSZQgIu2BLCAOyK/9VALIJi8B TNDIZRY82CZeiin27bVzDJZMlzoibSgY4eAXiOu5rBtgeALPfiimRXpndhg3LadsFL WBn8qBMe2uftdlk7rrAnEPsevMuQcwbqSzI+h6ZBgHR7tRPw+mvt3oV8B4EvGA4IqX +kEuowAnpDj0A== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang , Gang Yan Subject: [PATCH mptcp-next 6/7] Add MPTCP support to Socket class Date: Wed, 23 Jul 2025 13:16:18 +0800 Message-ID: X-Mailer: git-send-email 2.48.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 Signed-off-by: Gang Yan Signed-off-by: Geliang Tang --- .../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.ba= se/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) t= hrows IOException { (SocketAddress) null, stream); } =20 + /** + * Creates a stream socket and connects it to the specified port + * number on the named host using Multipath TCP (MPTCP) or TCP + * protocol. + *

+ * 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.

+ *

+ * If the application has specified a {@linkplain SocketImplFactory cl= ient + * socket implementation factory}, that factory's + * {@linkplain SocketImplFactory#createSocketImpl() createSocketImpl} + * method is called to create the actual socket implementation. Otherw= ise + * a system-default socket implementation is created. + * + * @param host the host name, or {@code null} for the loopbac= k 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 s= ocket. + * @throws IllegalArgumentException if the stream parameter is {@c= ode 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) th= rows IOException { + this(host !=3D 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() { } } =20 + /** + * Initialize a new Socket that is connected to the given remote addre= ss. + * The MPTCP or TCP protocol socket is optionally bound to a local add= ress + * 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 datag= ram sockets"); + } + assert address instanceof InetSocketAddress; + + // create the SocketImpl and the underlying socket + SocketImpl impl =3D createImpl(mptcp); + impl.create(stream); + + this.impl =3D impl; + this.state =3D SOCKET_CREATED; + + try { + if (localAddr !=3D null) { + bind(localAddr); + } + connect(address); + } catch (Throwable throwable) { + closeSuppressingExceptions(throwable); + throw throwable; + } + } + + /** + * Create a new SocketImpl for a connecting/client socket. The SocketI= mpl + * is created without an underlying socket. + * + * @param mptcp create a socket with MPTCP or TCP protocol. + */ + private static SocketImpl createImpl(boolean mptcp) { + SocketImplFactory factory =3D Socket.factory; + if (factory !=3D null) { + return factory.createSocketImpl(); + } else { + // create a SOCKS SocketImpl that delegates to a platform Sock= etImpl + SocketImpl delegate =3D SocketImpl.createPlatformSocketImpl(fa= lse, mptcp); + return new SocksSocketImpl(delegate); + } + } + /** * Returns the {@code SocketImpl} for this Socket, creating it, and the * underlying socket, if required. --=20 2.48.1 From nobody Wed Sep 17 18:02:55 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6164A2F4A for ; Wed, 23 Jul 2025 05:17:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753247826; cv=none; b=KbjdM58inUxL4SpiEERoAPBqKY3fG2yVY4DAtZG6Ky6iPuSBetGIeD+vVB2wjBipNjIZkPKdwLpu0Eu6s+OA9EvXY8cWmtm/PRQlklB9KGegRgJ4/dOXLBn5NX4PwOXT1feO/IMxrpvl/zdIYcrRRxTH+HAVbwmtBKsNhcNUCC0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753247826; c=relaxed/simple; bh=DhltbvoniosF2lAtqndy5OpqR3jyVD6NwQolSy2/ky8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ih93Ta/rkzZgoJIID463+p43YOcQhbl8gjVsOiA07jUXF5/nRk4QNNY1AZGhyTRslorlCJOLpPcDCLY209C7jflW+/xro/NdvlfwLQcKHrL6C/Yft6IFQlzseA3mzoNBYeydQzYc6yBHL0/NK1ZARtiDqlmBtNXAcFCg+QfkRUY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Wlaqkogu; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Wlaqkogu" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0E703C4CEE7; Wed, 23 Jul 2025 05:16:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1753247826; bh=DhltbvoniosF2lAtqndy5OpqR3jyVD6NwQolSy2/ky8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Wlaqkoguj/llbpGBF7OVtIgdHCz9xVPpZuYg4VHBvmBVmzaDodkI8AHST4ooN+zbK eT3tPxpqLgs4zq69l1jNRCXjZkUQNxGMJG6W+fH9D3Gin9hsO4B6DZPbUyIRebTE3T eHWSnHt4gzejtR8drOKRq1IV/kXz5pJtwz1jdrlNtVQMPqgpu4mbdSGAMs3l7Iv52J u713OnlZaec6TaV+Qf7ASpUtTISIoqQ8DzEenXf8VgteHokhFHE6btjEOorA4cPjXg sx9jeze6YT5xn6dATSTZq+AXWMOV/X5d6zGL95l1r3RPgWKutd7UThdLP4RzVldFqF c+e6WWa2q4rGA== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang , Gang Yan Subject: [PATCH mptcp-next 7/7] Add test cases for MPTCP socket functionality Date: Wed, 23 Jul 2025 13:16:19 +0800 Message-ID: <4e7279b9bf9118e89c57221546f3f678517b91da.1753247666.git.geliang@kernel.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 Signed-off-by: Gang Yan Signed-off-by: Geliang Tang --- .../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/jav= a/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 versi= on + * 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 =3D 12345; + + try (ServerSocket serverSocket =3D new ServerSocket(PORT, 50, null, true= )) { + System.out.println("Server started, waiting for client connection ..."); + + Socket clientSocket =3D serverSocket.accept(); + System.out.println("Client connected: " + clientSocket.getInetAddress()= ); + + BufferedReader in =3D new BufferedReader( + new InputStreamReader(clientSocket.getInputStream())); + PrintWriter out =3D new PrintWriter( + clientSocket.getOutputStream(), true); + + String inputLine; + while ((inputLine =3D in.readLine()) !=3D 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 versi= on + * 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 =3D "localhost"; + final int PORT =3D 12345; + =20 + try (Socket socket =3D new Socket(HOST, PORT, true, true)) { + System.out.println("Connected to server"); + =20 + BufferedReader in =3D new BufferedReader( + new InputStreamReader(socket.getInputStream())); + PrintWriter out =3D new PrintWriter( + socket.getOutputStream(), true); + =20 + BufferedReader stdIn =3D new BufferedReader( + new InputStreamReader(System.in)); + =20 + String userInput; + System.out.println("Enter message (type 'exit' to quit):"); + while ((userInput =3D stdIn.readLine()) !=3D null) { + out.println(userInput); + =20 + System.out.println("Server response: " + in.readLine()); + =20 + if ("exit".equalsIgnoreCase(userInput)) { + break; + } + } + =20 + 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()); + } + } +} --=20 2.48.1