LibCore: Implement TCPServer on Windows

This commit is contained in:
ayeteadoe 2025-07-14 01:16:11 -07:00 committed by Andrew Kaster
commit cc3cabc768
Notes: github-actions[bot] 2025-08-07 02:26:27 +00:00
5 changed files with 174 additions and 6 deletions

View file

@ -2,6 +2,7 @@
* Copyright (c) 2018-2021, Andreas Kling <andreas@ladybird.org>
* Copyright (c) 2021, sin-ack <sin-ack@protonmail.com>
* Copyright (c) 2025, stasoid <stasoid@yahoo.com>
* Copyright (c) 2025, ayeteadoe <ayeteadoe@gmail.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -279,4 +280,15 @@ ErrorOr<NonnullOwnPtr<TCPSocket>> TCPSocket::connect(SocketAddress const& addres
return socket;
}
ErrorOr<NonnullOwnPtr<TCPSocket>> TCPSocket::adopt_fd(int fd)
{
if (static_cast<SOCKET>(fd) == INVALID_SOCKET)
return Error::from_windows_error();
auto socket = TRY(adopt_nonnull_own_or_enomem(new (nothrow) TCPSocket()));
socket->m_helper.set_fd(fd);
socket->setup_notifier();
return socket;
}
}