vpcd: add TCP_NODELAY socket option

Idea from @jetfire13

closes https://github.com/frankmorgner/vsmartcard/pull/323

(cherry picked from commit 92d918e56d25c7c29dabbcac030a30655aeaa3a1)
This commit is contained in:
Frank Morgner
2026-02-28 01:36:47 +01:00
committed by Christoph Honal
parent 002e61dadf
commit 0f84236f4a

View File

@@ -39,6 +39,7 @@ typedef WORD uint16_t;
#include <arpa/inet.h>
#include <netdb.h>
#include <netinet/in.h>
#include <netinet/tcp.h> /* for TCP_NODELAY */
#include <poll.h>
#include <stdint.h>
#include <sys/socket.h>
@@ -47,6 +48,7 @@ typedef WORD uint16_t;
#define INVALID_SOCKET -1
#endif
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
@@ -110,6 +112,10 @@ static SOCKET opensock(unsigned short port)
if (setsockopt(sock, SOL_SOCKET, SO_NOSIGPIPE, (void *) &yes, sizeof yes) != 0)
goto err;
#endif
#ifdef TCP_NODELAY
if(setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (void *) &yes, sizeof yes) != 0)
goto err;
#endif
memset(&server_sockaddr, 0, sizeof server_sockaddr);
server_sockaddr.sin_family = PF_INET;