mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-25 19:51:59 +00:00
LibCore: Implement System::socketpair on Windows
This commit is contained in:
parent
886a8fca86
commit
4ae3522b10
Notes:
github-actions[bot]
2025-02-14 16:40:14 +00:00
Author: https://github.com/stasoid
Commit: 4ae3522b10
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2952
Reviewed-by: https://github.com/ADKaster ✅
6 changed files with 124 additions and 3 deletions
|
@ -4,7 +4,7 @@
|
|||
* Copyright (c) 2021-2022, Sam Atkins <atkinssj@serenityos.org>
|
||||
* Copyright (c) 2022, Matthias Zimmerman <matthias291999@gmail.com>
|
||||
* Copyright (c) 2023, Cameron Youell <cameronyouell@gmail.com>
|
||||
* Copyright (c) 2024, stasoid <stasoid@yahoo.com>
|
||||
* Copyright (c) 2024-2025, stasoid <stasoid@yahoo.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -19,6 +19,8 @@
|
|||
|
||||
namespace Core::System {
|
||||
|
||||
int windows_socketpair(SOCKET socks[2], int make_overlapped);
|
||||
|
||||
static void invalid_parameter_handler(wchar_t const*, wchar_t const*, wchar_t const*, unsigned int, uintptr_t)
|
||||
{
|
||||
}
|
||||
|
@ -225,6 +227,20 @@ bool is_socket(int handle)
|
|||
return GetFileType(to_handle(handle)) == FILE_TYPE_PIPE;
|
||||
}
|
||||
|
||||
ErrorOr<void> socketpair(int domain, int type, int protocol, int sv[2])
|
||||
{
|
||||
if (domain != AF_LOCAL || type != SOCK_STREAM || protocol != 0)
|
||||
return Error::from_string_literal("Unsupported argument value");
|
||||
|
||||
SOCKET socks[2] = {};
|
||||
if (windows_socketpair(socks, true))
|
||||
return Error::from_windows_error();
|
||||
|
||||
sv[0] = socks[0];
|
||||
sv[1] = socks[1];
|
||||
return {};
|
||||
}
|
||||
|
||||
ErrorOr<void> sleep_ms(u32 milliseconds)
|
||||
{
|
||||
Sleep(milliseconds);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue