From ca541f679941b8dc0c623d54c4255d82bb58bac7 Mon Sep 17 00:00:00 2001 From: reito Date: Sun, 8 Dec 2024 23:06:47 +0800 Subject: [PATCH] src: getpeername getsockname --- src/win/pipe.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/win/pipe.c b/src/win/pipe.c index 262e06d1..6c983316 100644 --- a/src/win/pipe.c +++ b/src/win/pipe.c @@ -2940,6 +2940,15 @@ int uv_pipe_getsockname(const uv_pipe_t* handle, char* buffer, size_t* size) { if (buffer == NULL || size == NULL || *size == 0) return UV_EINVAL; + if (handle->flags & UV_HANDLE_WIN_UDS_PIPE) { + if (handle->pathname != NULL) { + *size = strlen(handle->pathname); + memcpy(buffer, handle->pathname, *size); + } + + return 0; + } + if (handle->flags & UV_HANDLE_BOUND) return uv__pipe_getname(handle, buffer, size); @@ -2961,6 +2970,15 @@ int uv_pipe_getpeername(const uv_pipe_t* handle, char* buffer, size_t* size) { if (handle->flags & UV_HANDLE_BOUND) return UV_ENOTCONN; + if (handle->flags & UV_HANDLE_WIN_UDS_PIPE) { + if (handle->pathname != NULL) { + *size = strlen(handle->pathname); + memcpy(buffer, handle->pathname, *size); + } + + return 0; + } + if (handle->handle != INVALID_HANDLE_VALUE) return uv__pipe_getname(handle, buffer, size); @@ -2993,6 +3011,11 @@ int uv_pipe_chmod(uv_pipe_t* handle, int mode) { if (handle == NULL || handle->handle == INVALID_HANDLE_VALUE) return UV_EBADF; + if (handle->flags & UV_HANDLE_WIN_UDS_PIPE) { + /* Unix domain socket doesn't support this. */ + return UV_ENOSYS; + } + if (mode != UV_READABLE && mode != UV_WRITABLE && mode != (UV_WRITABLE | UV_READABLE))