mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-12-07 21:59:54 +00:00
LibCore+RequestServer: Implement Core::System::send on Windows
This commit is contained in:
parent
85fd4d5ea1
commit
079a2ba36a
Notes:
github-actions[bot]
2025-12-01 13:56:41 +00:00
Author: https://github.com/trflynn89
Commit: 079a2ba36a
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6983
2 changed files with 23 additions and 14 deletions
|
|
@ -254,6 +254,28 @@ ErrorOr<int> accept(int sockfd, struct sockaddr* addr, socklen_t* addr_size)
|
|||
return fd;
|
||||
}
|
||||
|
||||
ErrorOr<void> connect(int sockfd, struct sockaddr const* address, socklen_t address_length)
|
||||
{
|
||||
if (::connect(sockfd, address, address_length) == SOCKET_ERROR)
|
||||
return Error::from_windows_error();
|
||||
return {};
|
||||
}
|
||||
|
||||
ErrorOr<ssize_t> send(int sockfd, ReadonlyBytes data, int flags)
|
||||
{
|
||||
auto sent = ::send(sockfd, reinterpret_cast<char const*>(data.data()), static_cast<int>(data.size()), flags);
|
||||
|
||||
if (sent == SOCKET_ERROR) {
|
||||
auto error = WSAGetLastError();
|
||||
|
||||
return error == WSAEWOULDBLOCK
|
||||
? Error::from_errno(EWOULDBLOCK)
|
||||
: Error::from_windows_error(error);
|
||||
}
|
||||
|
||||
return sent;
|
||||
}
|
||||
|
||||
ErrorOr<ssize_t> sendto(int sockfd, ReadonlyBytes data, int flags, struct sockaddr const* destination, socklen_t destination_length)
|
||||
{
|
||||
auto sent = ::sendto(sockfd, reinterpret_cast<char const*>(data.data()), static_cast<int>(data.size()), flags, destination, destination_length);
|
||||
|
|
@ -361,13 +383,6 @@ ErrorOr<AddressInfoVector> getaddrinfo(char const* nodename, char const* servnam
|
|||
return AddressInfoVector { move(addresses), results };
|
||||
}
|
||||
|
||||
ErrorOr<void> connect(int socket, struct sockaddr const* address, socklen_t address_length)
|
||||
{
|
||||
if (::connect(socket, address, address_length) == SOCKET_ERROR)
|
||||
return Error::from_windows_error();
|
||||
return {};
|
||||
}
|
||||
|
||||
ErrorOr<void> kill(pid_t pid, int signal)
|
||||
{
|
||||
if (signal == SIGTERM) {
|
||||
|
|
|
|||
|
|
@ -59,13 +59,7 @@ ErrorOr<RequestPipe> RequestPipe::create()
|
|||
ErrorOr<ssize_t> RequestPipe::write(ReadonlyBytes bytes)
|
||||
{
|
||||
#if defined(AK_OS_WINDOWS)
|
||||
auto sent = ::send(m_writer_fd, reinterpret_cast<char const*>(bytes.data()), bytes.size(), 0);
|
||||
if (sent == SOCKET_ERROR) {
|
||||
if (WSAGetLastError() == WSAEWOULDBLOCK)
|
||||
return Error::from_errno(EWOULDBLOCK);
|
||||
return Error::from_windows_error();
|
||||
}
|
||||
return sent;
|
||||
return Core::System::send(m_writer_fd, bytes, 0);
|
||||
#else
|
||||
return Core::System::write(m_writer_fd, bytes);
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue