]> git.plutz.net Git - quickjs_net/commitdiff
bugfix use correct address struct for ip6 send, set socket family for unix client...
authorPaul Hänsch <paul@plutz.net>
Mon, 16 Mar 2026 21:46:10 +0000 (22:46 +0100)
committerPaul Hänsch <paul@plutz.net>
Mon, 16 Mar 2026 21:46:10 +0000 (22:46 +0100)
socket.c

index 341474c5a75017c2b71a84b878be46c8d5cf84e1..cedd5119fc55de87b3207e83f7359d7b8e4eba71 100644 (file)
--- a/socket.c
+++ b/socket.c
@@ -200,8 +200,9 @@ static JSValue js_sock_accept(
   ) {
     memcpy(&(newdata->bind), &(data->bind), sizeof(data->bind));
     newdata->connected = 1;
-    JS_SetOpaque(new, newdata);
+    newdata->type = data->type;
     (void) sock_set_timeout(newdata, data->timeout);
+    JS_SetOpaque(new, newdata);
     return new;
 
   } else {
@@ -242,10 +243,13 @@ static JSValue js_sock_send(
 
   // Read Argument either as ArrayBuffer or String
   if ( (buf = JS_GetArrayBuffer(ctx, &len, argv[0])) ) {
-    len = sendto(data->fd, buf, len, flags, to, to ? sizeof(*to) : 0);
-
+    len = sendto(data->fd, buf, len, flags, to,
+                 to ? sizeof(struct sockaddr_storage) : 0
+                );
   } else if ( (buf = (uint8_t*) JS_ToCStringLen(ctx, &len, argv[0])) ) {
-    len = sendto(data->fd, buf, len, flags, to, to ? sizeof(*to) : 0);
+    len = sendto(data->fd, buf, len, flags, to,
+                 to ? sizeof(struct sockaddr_storage) : 0
+                );
     JS_FreeCString(ctx, (char *) buf);
 
   } else return JS_ThrowTypeError(ctx,
@@ -492,6 +496,7 @@ static int net_unix_bind(SocketData *so, const char *path, size_t plen, int con)
     && !sock_set_timeout(so, net_timeout)
     && !connect(so->fd,(struct sockaddr *) addr ,sizeof(*addr))
   ) {
+    so->bind.ss_family = AF_UNIX;
     so->connected = 1;
     return 0;
   } else if (!con