From b5db1f7fde63290624bfe7308b74d3b368f18d23 Mon Sep 17 00:00:00 2001
From: rswindell <>
Date: Thu, 8 May 2003 22:54:04 +0000
Subject: [PATCH] Added support for TCP_NODELAY socket option.

---
 exec/load/sockdefs.js | 1 +
 src/sbbs3/js_socket.c | 7 +++++--
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/exec/load/sockdefs.js b/exec/load/sockdefs.js
index 7295dcc521..f41a6d4ae6 100644
--- a/exec/load/sockdefs.js
+++ b/exec/load/sockdefs.js
@@ -96,4 +96,5 @@ var sockopts = [
 	"BROADCAST",
 	"OOBINLINE",
 	"ACCEPTCONN",
+	"TCP_NODELAY",
 ];
\ No newline at end of file
diff --git a/src/sbbs3/js_socket.c b/src/sbbs3/js_socket.c
index 0953973c5d..1dc1d90ec0 100644
--- a/src/sbbs3/js_socket.c
+++ b/src/sbbs3/js_socket.c
@@ -848,7 +848,8 @@ js_getsockopt(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval
 	opt = sockopt(JS_GetStringBytes(JS_ValueToString(cx,argv[0])));
 	len = sizeof(val);
 
-	if(getsockopt(p->sock,SOL_SOCKET,opt,(void*)&val,&len)==0) {
+	if(getsockopt(p->sock,opt==TCP_NODELAY ? IPPROTO_TCP : SOL_SOCKET
+		,opt, (void*)&val, &len)==0) {
 		dbprintf(FALSE, p, "option %d = %d",opt,val);
 		JS_NewNumberValue(cx,val,rval);
 	} else {
@@ -877,7 +878,9 @@ js_setsockopt(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval
 	opt = sockopt(JS_GetStringBytes(JS_ValueToString(cx,argv[0])));
 	JS_ValueToInt32(cx,argv[1],&val);
 
-	*rval = BOOLEAN_TO_JSVAL(setsockopt(p->sock,SOL_SOCKET,opt,(char*)&val,sizeof(val))==0);
+	*rval = BOOLEAN_TO_JSVAL(
+		setsockopt(p->sock,opt==TCP_NODELAY ? IPPROTO_TCP : SOL_SOCKET
+					,opt, (char*)&val, sizeof(val))==0);
 	p->last_error=ERROR_VALUE;
 
 	return(JS_TRUE);
-- 
GitLab