From: Paul Hänsch Date: Mon, 16 Mar 2026 21:46:10 +0000 (+0100) Subject: bugfix use correct address struct for ip6 send, set socket family for unix client... X-Git-Url: https://git.plutz.net/?a=commitdiff_plain;h=a0dace2ed07ed1cea82c25ad469293c52c5c6ec8;p=quickjs_net bugfix use correct address struct for ip6 send, set socket family for unix client connections --- diff --git a/socket.c b/socket.c index 341474c..cedd511 100644 --- 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