Skip to content

Commit

Permalink
docs: Add information about pipe:bind2 and pipe:connect2
Browse files Browse the repository at this point in the history
  • Loading branch information
zhaozg committed Jul 4, 2023
1 parent 984632a commit 8e2f306
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
45 changes: 45 additions & 0 deletions docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -1943,6 +1943,51 @@ read_pipe:read_start(function(err, chunk)
print(chunk)
end)
```
### `uv.pipe_bind2(pipe, name, [flags])`

> method form `pipe:bind2(name, [flags])`
**Parameters:**
- `pipe`: `uv_pipe_t userdata`
- `name`: `string`
- `flags`: `integer`(default: 0)

Bind the pipe to a file path (Unix) or a name (Windows).

`Flags` must be zero or `uv.constants.PIPE_NO_TRUNCATE`. Returns `EINVAL` for unsupported flags without performing the bind operation.

Supports Linux abstract namespace sockets. namelen must include the leading '\0' byte but not the trailing nul byte.

**Returns:** `0` or `fail`

**Note**:
1. Paths on Unix get truncated to sizeof(sockaddr_un.sun_path) bytes,
typically between 92 and 108 bytes.
2. New in version 1.46.0.

### `uv.pipe_connect2(pipe, name, [flags], [callback])`

> method form `pipe:connect2(name, [flags], [callback])`
**Parameters:**
- `pipe`: `uv_pipe_t userdata`
- `name`: `string`
- `flags`: `integer`(default: 0)
- `callback`: `callable` or `nil`
- `err`: `nil` or `string`

Connect to the Unix domain socket or the named pipe.

`Flags` must be zero or `uv.constants.PIPE_NO_TRUNCATE`. Returns `EINVAL` for unsupported flags without performing the bind operation.

Supports Linux abstract namespace sockets. namelen must include the leading nul byte but not the trailing nul byte.

**Returns:** `uv_connect_t userdata` or `fail`

**Note**:
1. Paths on Unix get truncated to sizeof(sockaddr_un.sun_path) bytes,
typically between 92 and 108 bytes.
2. New in version 1.46.0.

## `uv_tty_t` — TTY handle

Expand Down
1 change: 1 addition & 0 deletions tests/test-pipe.lua
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ return require('lib/tap')(function (test)
end, "1.41.0")

test("pipe getsockname abstract", function(print, p, expect, uv)
-- https://github.com/libuv/libuv/blob/v1.x/test/test-pipe-getsockname.c#L164-L210
local isWindows = require('lib/utils').isWindows
local isLinux = require('lib/utils').isLinux

Expand Down

0 comments on commit 8e2f306

Please sign in to comment.