mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-28 21:26:22 +00:00
LibCore: Implement UDPSocket::connect() on Windows
This commit is contained in:
parent
ba15348d56
commit
e01a95f6cd
Notes:
github-actions[bot]
2025-08-07 02:25:48 +00:00
Author: https://github.com/ayeteadoe
Commit: e01a95f6cd
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5435
Reviewed-by: https://github.com/ADKaster ✅
Reviewed-by: https://github.com/R-Goc
1 changed files with 20 additions and 0 deletions
|
@ -290,6 +290,26 @@ ErrorOr<void> Socket::connect_local(int fd, ByteString const& path)
|
||||||
return System::connect(fd, bit_cast<struct sockaddr*>(&addr), sizeof(addr));
|
return System::connect(fd, bit_cast<struct sockaddr*>(&addr), sizeof(addr));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ErrorOr<NonnullOwnPtr<UDPSocket>> UDPSocket::connect(SocketAddress const& address, Optional<AK::Duration> timeout)
|
||||||
|
{
|
||||||
|
auto socket = adopt_own(*new UDPSocket);
|
||||||
|
|
||||||
|
auto socket_domain = SocketDomain::Inet6;
|
||||||
|
if (address.type() == SocketAddress::Type::IPv4)
|
||||||
|
socket_domain = SocketDomain::Inet;
|
||||||
|
|
||||||
|
auto fd = TRY(create_fd(socket_domain, SocketType::Datagram));
|
||||||
|
socket->m_helper.set_fd(fd);
|
||||||
|
if (timeout.has_value()) {
|
||||||
|
TRY(socket->m_helper.set_receive_timeout(timeout.value()));
|
||||||
|
}
|
||||||
|
|
||||||
|
TRY(connect_inet(fd, address));
|
||||||
|
|
||||||
|
socket->setup_notifier();
|
||||||
|
return socket;
|
||||||
|
}
|
||||||
|
|
||||||
ErrorOr<NonnullOwnPtr<TCPSocket>> TCPSocket::connect(ByteString const& host, u16 port)
|
ErrorOr<NonnullOwnPtr<TCPSocket>> TCPSocket::connect(ByteString const& host, u16 port)
|
||||||
{
|
{
|
||||||
auto ip_addresses = TRY(resolve_host(host, SocketType::Stream));
|
auto ip_addresses = TRY(resolve_host(host, SocketType::Stream));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue