mirror of
https://github.com/RGBCube/serenity
synced 2025-05-22 14:25:07 +00:00
LibCore: Put all classes in the Core namespace and remove the leading C
I've been wanting to do this for a long time. It's time we start being consistent about how this stuff works. The new convention is: - "LibFoo" is a userspace library that provides the "Foo" namespace. That's it :^) This was pretty tedious to convert and I didn't even start on LibGUI yet. But it's coming up next.
This commit is contained in:
parent
b7e3810b5c
commit
2d39da5405
265 changed files with 1380 additions and 1167 deletions
|
@ -32,24 +32,26 @@
|
|||
#include <stdio.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
CUdpServer::CUdpServer(CObject* parent)
|
||||
: CObject(parent)
|
||||
namespace Core {
|
||||
|
||||
UdpServer::UdpServer(Object* parent)
|
||||
: Object(parent)
|
||||
{
|
||||
m_fd = socket(AF_INET, SOCK_DGRAM | SOCK_NONBLOCK | SOCK_CLOEXEC, 0);
|
||||
ASSERT(m_fd >= 0);
|
||||
}
|
||||
|
||||
CUdpServer::~CUdpServer()
|
||||
UdpServer::~UdpServer()
|
||||
{
|
||||
}
|
||||
|
||||
bool CUdpServer::listen(const IPv4Address& address, u16 port)
|
||||
bool UdpServer::listen(const IPv4Address& address, u16 port)
|
||||
{
|
||||
if (m_listening)
|
||||
return false;
|
||||
|
||||
int rc;
|
||||
auto socket_address = CSocketAddress(address, port);
|
||||
auto socket_address = SocketAddress(address, port);
|
||||
auto in = socket_address.to_sockaddr_in();
|
||||
rc = ::bind(m_fd, (const sockaddr*)&in, sizeof(in));
|
||||
ASSERT(rc == 0);
|
||||
|
@ -58,7 +60,7 @@ bool CUdpServer::listen(const IPv4Address& address, u16 port)
|
|||
ASSERT(rc == 0);
|
||||
m_listening = true;
|
||||
|
||||
m_notifier = CNotifier::construct(m_fd, CNotifier::Event::Read);
|
||||
m_notifier = Notifier::construct(m_fd, Notifier::Event::Read);
|
||||
m_notifier->on_ready_to_read = [this] {
|
||||
if (on_ready_to_accept)
|
||||
on_ready_to_accept();
|
||||
|
@ -66,7 +68,7 @@ bool CUdpServer::listen(const IPv4Address& address, u16 port)
|
|||
return true;
|
||||
}
|
||||
|
||||
RefPtr<CUdpSocket> CUdpServer::accept()
|
||||
RefPtr<UdpSocket> UdpServer::accept()
|
||||
{
|
||||
ASSERT(m_listening);
|
||||
sockaddr_in in;
|
||||
|
@ -77,10 +79,10 @@ RefPtr<CUdpSocket> CUdpServer::accept()
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
return CUdpSocket::construct(accepted_fd);
|
||||
return UdpSocket::construct(accepted_fd);
|
||||
}
|
||||
|
||||
Optional<IPv4Address> CUdpServer::local_address() const
|
||||
Optional<IPv4Address> UdpServer::local_address() const
|
||||
{
|
||||
if (m_fd == -1)
|
||||
return {};
|
||||
|
@ -93,7 +95,7 @@ Optional<IPv4Address> CUdpServer::local_address() const
|
|||
return IPv4Address(address.sin_addr.s_addr);
|
||||
}
|
||||
|
||||
Optional<u16> CUdpServer::local_port() const
|
||||
Optional<u16> UdpServer::local_port() const
|
||||
{
|
||||
if (m_fd == -1)
|
||||
return {};
|
||||
|
@ -105,3 +107,5 @@ Optional<u16> CUdpServer::local_port() const
|
|||
|
||||
return ntohs(address.sin_port);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue