Tests/LibCore: Enable TestLibCoreStream in Windows CI

This commit is contained in:
ayeteadoe 2025-07-14 15:27:18 -07:00 committed by Andrew Kaster
commit 688d0ada97
Notes: github-actions[bot] 2025-08-07 02:25:42 +00:00
5 changed files with 89 additions and 38 deletions

View file

@ -116,9 +116,9 @@ ErrorOr<size_t> PosixSocketHelper::pending_bytes() const
return Error::from_windows_error(WSAENOTCONN);
}
int value;
u_long value;
TRY(System::ioctl(m_fd, FIONREAD, &value));
return static_cast<size_t>(value);
return value;
}
void PosixSocketHelper::setup_notifier()
@ -310,6 +310,21 @@ ErrorOr<NonnullOwnPtr<UDPSocket>> UDPSocket::connect(SocketAddress const& addres
return socket;
}
ErrorOr<Bytes> UDPSocket::read_some(Bytes buffer)
{
auto pending_bytes = TRY(this->pending_bytes());
if (pending_bytes > buffer.size()) {
// With UDP datagrams, reading a datagram into a buffer that's
// smaller than the datagram's size will cause the rest of the
// datagram to be discarded. That's not very nice, so let's bail
// early, telling the caller that he should allocate a bigger
// buffer.
return Error::from_errno(WSAEMSGSIZE);
}
return m_helper.read(buffer, default_flags());
}
ErrorOr<NonnullOwnPtr<TCPSocket>> TCPSocket::connect(ByteString const& host, u16 port)
{
auto ip_addresses = TRY(resolve_host(host, SocketType::Stream));