mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 11:18:11 +00:00
Kernel: More sockets work. Fleshing out accept().
This commit is contained in:
parent
1d66670ad7
commit
54b1d6f57f
7 changed files with 103 additions and 9 deletions
|
@ -8,7 +8,7 @@ RetainPtr<Socket> Socket::create(int domain, int type, int protocol, int& error)
|
|||
(void)protocol;
|
||||
switch (domain) {
|
||||
case AF_LOCAL:
|
||||
return LocalSocket::create(type);
|
||||
return LocalSocket::create(type & SOCK_TYPE_MASK);
|
||||
default:
|
||||
error = EAFNOSUPPORT;
|
||||
return nullptr;
|
||||
|
@ -26,4 +26,25 @@ Socket::~Socket()
|
|||
{
|
||||
}
|
||||
|
||||
bool Socket::listen(int backlog, int& error)
|
||||
{
|
||||
LOCKER(m_lock);
|
||||
if (m_type != SOCK_STREAM) {
|
||||
error = -EOPNOTSUPP;
|
||||
return false;
|
||||
}
|
||||
m_backlog = backlog;
|
||||
m_listening = true;
|
||||
kprintf("Socket{%p} listening with backlog=%d\n", m_backlog);
|
||||
return true;
|
||||
}
|
||||
|
||||
RetainPtr<Socket> Socket::accept()
|
||||
{
|
||||
LOCKER(m_lock);
|
||||
if (m_pending.is_empty())
|
||||
return nullptr;
|
||||
auto client = m_pending.take_first();
|
||||
m_clients.append(client.copy_ref());
|
||||
return client;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue