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

LibCore: Add CSocket::bind() (virtual) and CSocket::listen().

These will be useful for implementing server sockets.
This commit is contained in:
Andreas Kling 2019-07-26 22:39:16 +02:00
parent 2f373a27a2
commit be2b585ca6
7 changed files with 42 additions and 4 deletions

View file

@ -1,6 +1,8 @@
#pragma once
#include <AK/IPv4Address.h>
#include <sys/socket.h>
#include <sys/un.h>
class CSocketAddress {
public:
@ -41,6 +43,16 @@ public:
}
}
sockaddr_un to_sockaddr_un() const
{
ASSERT(type() == Type::Local);
sockaddr_un address;
address.sun_family = AF_LOCAL;
RELEASE_ASSERT(m_local_address.length() < (int)sizeof(address.sun_path));
strcpy(address.sun_path, m_local_address.characters());
return address;
}
private:
Type m_type { Type::Invalid };
IPv4Address m_ipv4_address;