1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 17:47:44 +00:00

LibCore+LookupServer: Implement and use UDPServer::send

This commit is contained in:
sin-ack 2021-09-11 20:11:30 +00:00 committed by Ali Mohammad Pur
parent 3da0c072f4
commit 0cca6cef95
5 changed files with 25 additions and 6 deletions

View file

@ -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;
}
}