mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-31 05:09:12 +00:00
LibCore+LookupServer: Implement and use UDPServer::send
This commit is contained in:
parent
3da0c072f4
commit
0cca6cef95
Notes:
sideshowbarker
2024-07-17 22:43:01 +09:00
Author: https://github.com/sin-ack
Commit: 0cca6cef95
Pull-request: https://github.com/SerenityOS/serenity/pull/9977
Reviewed-by: https://github.com/Dexesttp
Reviewed-by: https://github.com/alimpfard
Reviewed-by: https://github.com/awesomekling
5 changed files with 25 additions and 6 deletions
|
@ -102,4 +102,18 @@ Optional<u16> UDPServer::local_port() const
|
|||
return ntohs(address.sin_port);
|
||||
}
|
||||
|
||||
ErrorOr<size_t> UDPServer::send(ReadonlyBytes buffer, sockaddr_in const& to)
|
||||
{
|
||||
if (m_fd < 0) {
|
||||
return Error::from_errno(EBADF);
|
||||
}
|
||||
|
||||
auto result = ::sendto(m_fd, buffer.data(), buffer.size(), 0, (sockaddr const*)&to, sizeof(to));
|
||||
if (result < 0) {
|
||||
return Error::from_errno(errno);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue