Skip to content
Merged
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
9 changes: 9 additions & 0 deletions src/ps2link.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <pthread.h>
#ifndef _WIN32
#include <netinet/in.h>
#include <netinet/tcp.h>
#else
#include <windows.h>
#define sleep(x) Sleep(x * 1000)
Expand Down Expand Up @@ -52,6 +53,14 @@
// Connect to the request port.
request_socket = network_connect(hostname, 0x4711, SOCK_STREAM);

// Disable Nagle algorithm: without TCP_NODELAY, the two-part response
// (small header then data) interacts with PS2's delayed-ACK and causes
// ~200 ms stall per read() syscall, making fread() ~400x slower than read().
if (request_socket > 0) {
int one = 1;
setsockopt(request_socket, IPPROTO_TCP, TCP_NODELAY, &one, sizeof(one));
}

// Create the request thread.
if (request_socket > 0) { pthread_create(&request_thread_id, NULL, ps2link_thread_request, (void *)&request_thread_id); }

Expand Down