diff options
author | 2023-01-10 20:39:11 -0800 | |
---|---|---|
committer | 2023-01-10 20:39:11 -0800 | |
commit | 8911c398d9ed8a7bcb0413128f2db62b355e2adc (patch) | |
tree | e8f12ee5433092406acf6ac0c7914a367eaf72f3 | |
parent | 1738588f38413e9e29c899eaa8f22e4220f949ef (diff) | |
download | bun-8911c398d9ed8a7bcb0413128f2db62b355e2adc.tar.gz bun-8911c398d9ed8a7bcb0413128f2db62b355e2adc.tar.zst bun-8911c398d9ed8a7bcb0413128f2db62b355e2adc.zip |
Support socketPath
-rw-r--r-- | src/bun.js/net.exports.js | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/src/bun.js/net.exports.js b/src/bun.js/net.exports.js index 67fc66ae6..8d283dd1e 100644 --- a/src/bun.js/net.exports.js +++ b/src/bun.js/net.exports.js @@ -196,7 +196,13 @@ export const Socket = (function (InternalSocket) { connect(port, host, connectListener) { // TODO support IPC sockets + var path; if (typeof host == "function") { + if (typeof port === "string") { + path = port; + port = undefined; + } + connectListener = host; host = undefined; } @@ -223,13 +229,22 @@ export const Socket = (function (InternalSocket) { if (typeof bunTLS === "function") { tls = bunTLS.call(this, port, host); } - bunConnect({ - data: this, - hostname: host || "localhost", - port: port, - socket: Socket.#Handlers, - tls, - }); + bunConnect( + path + ? { + data: this, + unix: path, + socket: Socket.#Handlers, + tls, + } + : { + data: this, + hostname: host || "localhost", + port: port, + socket: Socket.#Handlers, + tls, + }, + ); return this; } |