1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-04 20:57:35 +00:00

Kernel: Make Socket inherit from File.

This commit is contained in:
Andreas Kling 2019-05-03 20:42:43 +02:00
parent 03da7046bd
commit 2470fdcd9b
18 changed files with 81 additions and 73 deletions

View file

@ -1,3 +1,4 @@
#include <Kernel/FileSystem/FileDescriptor.h>
#include <Kernel/Net/Socket.h>
#include <Kernel/Net/LocalSocket.h>
#include <Kernel/Net/IPv4Socket.h>
@ -119,3 +120,22 @@ void Socket::load_send_deadline()
m_send_deadline.tv_sec += (m_send_timeout.tv_usec / 1000000) * 1;
m_send_deadline.tv_usec %= 1000000;
}
static const char* to_string(SocketRole role)
{
switch (role) {
case SocketRole::Listener:
return "Listener";
case SocketRole::Accepted:
return "Accepted";
case SocketRole::Connected:
return "Connected";
default:
return "None";
}
}
String Socket::absolute_path(FileDescriptor& descriptor) const
{
return String::format("socket:%x (role: %s)", this, to_string(descriptor.socket_role()));
}