mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-16 22:42:18 +00:00
LibCore: Implement LocalSocket::connect() on Windows
This commit is contained in:
parent
904f736b95
commit
6e7565766d
Notes:
github-actions[bot]
2025-08-07 02:26:16 +00:00
Author: https://github.com/ayeteadoe
Commit: 6e7565766d
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 26 additions and 0 deletions
|
@ -163,6 +163,19 @@ ErrorOr<int> LocalSocket::release_fd()
|
||||||
return fd;
|
return fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ErrorOr<NonnullOwnPtr<LocalSocket>> LocalSocket::connect(ByteString const& path, PreventSIGPIPE prevent_sigpipe)
|
||||||
|
{
|
||||||
|
auto socket = TRY(adopt_nonnull_own_or_enomem(new (nothrow) LocalSocket(prevent_sigpipe)));
|
||||||
|
|
||||||
|
auto fd = TRY(create_fd(SocketDomain::Local, SocketType::Stream));
|
||||||
|
socket->m_helper.set_fd(fd);
|
||||||
|
|
||||||
|
TRY(connect_local(fd, path));
|
||||||
|
|
||||||
|
socket->setup_notifier();
|
||||||
|
return socket;
|
||||||
|
}
|
||||||
|
|
||||||
ErrorOr<int> Socket::create_fd(SocketDomain domain, SocketType type)
|
ErrorOr<int> Socket::create_fd(SocketDomain domain, SocketType type)
|
||||||
{
|
{
|
||||||
int socket_domain;
|
int socket_domain;
|
||||||
|
@ -252,6 +265,19 @@ ErrorOr<void> Socket::connect_inet(int fd, SocketAddress const& address)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ErrorOr<void> Socket::connect_local(int fd, ByteString const& path)
|
||||||
|
{
|
||||||
|
auto address = SocketAddress::local(path);
|
||||||
|
auto maybe_sockaddr = address.to_sockaddr_un();
|
||||||
|
if (!maybe_sockaddr.has_value()) {
|
||||||
|
dbgln("Core::Socket::connect_local: Could not obtain a sockaddr_un");
|
||||||
|
return Error::from_errno(EINVAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
auto addr = maybe_sockaddr.release_value();
|
||||||
|
return System::connect(fd, bit_cast<struct sockaddr*>(&addr), sizeof(addr));
|
||||||
|
}
|
||||||
|
|
||||||
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