From f57d16cf37533e063ae2ef8035dfe73f206f22bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Paj=C4=85k?= Date: Fri, 10 Jul 2026 21:36:41 +0200 Subject: [PATCH] Set TCP_NODELAY on the ps2link request socket ps2link fileio is a synchronous sequence of small request/response exchanges over the TCP request channel. With Nagle enabled on the client side, each response collides with the PS2 delayed ACKs and stalls ~200 ms, capping file serving at roughly 4 KB/s on a real console: a 424 KB texture took 106 seconds to serve, and a homebrew game booting entirely over host: took 10 minutes. With TCP_NODELAY on the SOCK_STREAM connect path the same texture serves in about a second and the same boot takes ~30 seconds (measured on a PAL console over 100 Mbit ethernet, Windows host); streaming 22 kHz music over host: becomes usable. --- src/network.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/network.c b/src/network.c index cdbf06d..81aa0f6 100644 --- a/src/network.c +++ b/src/network.c @@ -5,6 +5,7 @@ #include #include #include + #include #endif #include "network.h" @@ -36,6 +37,15 @@ // Open the socket. sock = socket(AF_INET, type, 0); if (sock < 0) { return -1; } + // Disable Nagle on the request channel: ps2link's fileio is a synchronous + // sequence of small request/response exchanges, and Nagle on this side + // colliding with the PS2's delayed ACKs stalls every exchange ~200ms + // (observed ~4 KB/s file serving; with TCP_NODELAY it is wire-speed). + if (type == SOCK_STREAM) { + int nodelay = 1; + setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (void *)&nodelay, sizeof(nodelay)); + } + // Connect the socket. if (connect(sock, (struct sockaddr *)&sockaddr, sizeof(struct sockaddr)) < 0) { return -2; }