mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 08:08:12 +00:00
Kernel: Move socket role tracking to the Socket class itself
This is more logical and allows us to solve the problem of non-blocking TCP sockets getting stuck in SocketRole::None. The only complication is that a single LocalSocket may be shared between two file descriptions (on the connect and accept sides), and should have two different roles depending from which side you look at it. To deal with it, Socket::role() is made a virtual method that accepts a file description, and LocalSocket internally tracks which FileDescription is the which one and returns a correct role.
This commit is contained in:
parent
d46c3b0b5b
commit
43ce6c5474
11 changed files with 103 additions and 95 deletions
|
@ -81,6 +81,12 @@ int UDPSocket::protocol_send(const void* data, int data_length)
|
|||
return data_length;
|
||||
}
|
||||
|
||||
KResult UDPSocket::protocol_connect(FileDescription&, ShouldBlock)
|
||||
{
|
||||
m_role = Role::Connected;
|
||||
return KSuccess;
|
||||
}
|
||||
|
||||
int UDPSocket::protocol_allocate_local_port()
|
||||
{
|
||||
static const u16 first_ephemeral_port = 32768;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue