mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-02-24 00:24:38 +00:00
Net: Let Socket have read/write wrappers around sendto/recvfrom
The situations in IPv4Socket and LocalSocket were mirrors of each other where one had implemented read/write as wrappers and the other had sendto/recvfrom as wrappers. Instead of this silliness, move read and write up to the Socket base. Then mark them final, so subclasses have no choice but to implement sendto and recvfrom.
This commit is contained in:
@@ -146,3 +146,13 @@ String Socket::absolute_path(const FileDescription& description) const
|
||||
{
|
||||
return String::format("socket:%x (role: %s)", this, to_string(description.socket_role()));
|
||||
}
|
||||
|
||||
ssize_t Socket::read(FileDescription& description, u8* buffer, ssize_t size)
|
||||
{
|
||||
return recvfrom(description, buffer, size, 0, nullptr, 0);
|
||||
}
|
||||
|
||||
ssize_t Socket::write(FileDescription& description, const u8* data, ssize_t size)
|
||||
{
|
||||
return sendto(description, data, size, 0, nullptr, 0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user