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:
parent
3da0c072f4
commit
0cca6cef95
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