Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/network.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <sys/socket.h>
#include <sys/time.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#endif

#include "network.h"
Expand Down Expand Up @@ -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; }

Expand Down