mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 20:57:35 +00:00
LibCore: Rename Udp classes to UDP
The kernel was already using the UDP prefix, and the TCP LibCore classes are also uppercased. Let's rename for consistency. Also order the LibCore Makefile alphabetically, because everywhere else seems to be doing that :)
This commit is contained in:
parent
149a9ba5d7
commit
5dc5b8a2b6
7 changed files with 47 additions and 47 deletions
|
@ -54,8 +54,8 @@ class TCPServer;
|
||||||
class TCPSocket;
|
class TCPSocket;
|
||||||
class Timer;
|
class Timer;
|
||||||
class TimerEvent;
|
class TimerEvent;
|
||||||
class UdpServer;
|
class UDPServer;
|
||||||
class UdpSocket;
|
class UDPSocket;
|
||||||
|
|
||||||
enum class TimerShouldFireWhenNotVisible;
|
enum class TimerShouldFireWhenNotVisible;
|
||||||
|
|
||||||
|
|
|
@ -1,33 +1,33 @@
|
||||||
OBJS = \
|
OBJS = \
|
||||||
ArgsParser.o \
|
ArgsParser.o \
|
||||||
|
ConfigFile.o \
|
||||||
DateTime.o \
|
DateTime.o \
|
||||||
IODevice.o \
|
DirIterator.o \
|
||||||
File.o \
|
|
||||||
SocketAddress.o \
|
|
||||||
Socket.o \
|
|
||||||
LocalSocket.o \
|
|
||||||
LocalServer.o \
|
|
||||||
TCPSocket.o \
|
|
||||||
TCPServer.o \
|
|
||||||
UdpSocket.o \
|
|
||||||
UdpServer.o \
|
|
||||||
ElapsedTimer.o \
|
ElapsedTimer.o \
|
||||||
MimeData.o \
|
Event.o \
|
||||||
Notifier.o \
|
EventLoop.o \
|
||||||
|
File.o \
|
||||||
|
Gzip.o \
|
||||||
|
HttpJob.o \
|
||||||
HttpRequest.o \
|
HttpRequest.o \
|
||||||
HttpResponse.o \
|
HttpResponse.o \
|
||||||
HttpJob.o \
|
IODevice.o \
|
||||||
|
LocalServer.o \
|
||||||
|
LocalSocket.o \
|
||||||
|
MimeData.o \
|
||||||
NetworkJob.o \
|
NetworkJob.o \
|
||||||
NetworkResponse.o \
|
NetworkResponse.o \
|
||||||
|
Notifier.o \
|
||||||
Object.o \
|
Object.o \
|
||||||
Timer.o \
|
|
||||||
EventLoop.o \
|
|
||||||
ConfigFile.o \
|
|
||||||
Event.o \
|
|
||||||
ProcessStatisticsReader.o \
|
ProcessStatisticsReader.o \
|
||||||
DirIterator.o \
|
Socket.o \
|
||||||
|
SocketAddress.o \
|
||||||
|
TCPServer.o \
|
||||||
|
TCPSocket.o \
|
||||||
|
Timer.o \
|
||||||
|
UDPServer.o \
|
||||||
|
UDPSocket.o \
|
||||||
UserInfo.o \
|
UserInfo.o \
|
||||||
Gzip.o \
|
|
||||||
puff.o
|
puff.o
|
||||||
|
|
||||||
LIBRARY = libcore.a
|
LIBRARY = libcore.a
|
||||||
|
|
|
@ -27,25 +27,25 @@
|
||||||
#include <AK/IPv4Address.h>
|
#include <AK/IPv4Address.h>
|
||||||
#include <AK/Types.h>
|
#include <AK/Types.h>
|
||||||
#include <LibCore/Notifier.h>
|
#include <LibCore/Notifier.h>
|
||||||
#include <LibCore/UdpServer.h>
|
#include <LibCore/UDPServer.h>
|
||||||
#include <LibCore/UdpSocket.h>
|
#include <LibCore/UDPSocket.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
|
|
||||||
UdpServer::UdpServer(Object* parent)
|
UDPServer::UDPServer(Object* parent)
|
||||||
: Object(parent)
|
: Object(parent)
|
||||||
{
|
{
|
||||||
m_fd = socket(AF_INET, SOCK_DGRAM | SOCK_NONBLOCK | SOCK_CLOEXEC, 0);
|
m_fd = socket(AF_INET, SOCK_DGRAM | SOCK_NONBLOCK | SOCK_CLOEXEC, 0);
|
||||||
ASSERT(m_fd >= 0);
|
ASSERT(m_fd >= 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
UdpServer::~UdpServer()
|
UDPServer::~UDPServer()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UdpServer::listen(const IPv4Address& address, u16 port)
|
bool UDPServer::listen(const IPv4Address& address, u16 port)
|
||||||
{
|
{
|
||||||
if (m_listening)
|
if (m_listening)
|
||||||
return false;
|
return false;
|
||||||
|
@ -68,7 +68,7 @@ bool UdpServer::listen(const IPv4Address& address, u16 port)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<UdpSocket> UdpServer::accept()
|
RefPtr<UDPSocket> UDPServer::accept()
|
||||||
{
|
{
|
||||||
ASSERT(m_listening);
|
ASSERT(m_listening);
|
||||||
sockaddr_in in;
|
sockaddr_in in;
|
||||||
|
@ -79,10 +79,10 @@ RefPtr<UdpSocket> UdpServer::accept()
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
return UdpSocket::construct(accepted_fd);
|
return UDPSocket::construct(accepted_fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
Optional<IPv4Address> UdpServer::local_address() const
|
Optional<IPv4Address> UDPServer::local_address() const
|
||||||
{
|
{
|
||||||
if (m_fd == -1)
|
if (m_fd == -1)
|
||||||
return {};
|
return {};
|
||||||
|
@ -95,7 +95,7 @@ Optional<IPv4Address> UdpServer::local_address() const
|
||||||
return IPv4Address(address.sin_addr.s_addr);
|
return IPv4Address(address.sin_addr.s_addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
Optional<u16> UdpServer::local_port() const
|
Optional<u16> UDPServer::local_port() const
|
||||||
{
|
{
|
||||||
if (m_fd == -1)
|
if (m_fd == -1)
|
||||||
return {};
|
return {};
|
|
@ -33,15 +33,15 @@
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
|
|
||||||
class UdpServer : public Object {
|
class UDPServer : public Object {
|
||||||
C_OBJECT(UdpServer)
|
C_OBJECT(UDPServer)
|
||||||
public:
|
public:
|
||||||
virtual ~UdpServer() override;
|
virtual ~UDPServer() override;
|
||||||
|
|
||||||
bool is_listening() const { return m_listening; }
|
bool is_listening() const { return m_listening; }
|
||||||
bool listen(const IPv4Address& address, u16 port);
|
bool listen(const IPv4Address& address, u16 port);
|
||||||
|
|
||||||
RefPtr<UdpSocket> accept();
|
RefPtr<UDPSocket> accept();
|
||||||
|
|
||||||
Optional<IPv4Address> local_address() const;
|
Optional<IPv4Address> local_address() const;
|
||||||
Optional<u16> local_port() const;
|
Optional<u16> local_port() const;
|
||||||
|
@ -49,7 +49,7 @@ public:
|
||||||
Function<void()> on_ready_to_accept;
|
Function<void()> on_ready_to_accept;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit UdpServer(Object* parent = nullptr);
|
explicit UDPServer(Object* parent = nullptr);
|
||||||
|
|
||||||
int m_fd { -1 };
|
int m_fd { -1 };
|
||||||
bool m_listening { false };
|
bool m_listening { false };
|
|
@ -24,23 +24,23 @@
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <LibCore/UdpSocket.h>
|
#include <LibCore/UDPSocket.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
|
|
||||||
UdpSocket::UdpSocket(int fd, Object* parent)
|
UDPSocket::UDPSocket(int fd, Object* parent)
|
||||||
: Socket(Socket::Type::UDP, parent)
|
: Socket(Socket::Type::UDP, parent)
|
||||||
{
|
{
|
||||||
// NOTE: This constructor is used by UdpServer::accept(), so the socket is already connected.
|
// NOTE: This constructor is used by UDPServer::accept(), so the socket is already connected.
|
||||||
m_connected = true;
|
m_connected = true;
|
||||||
set_fd(fd);
|
set_fd(fd);
|
||||||
set_mode(IODevice::ReadWrite);
|
set_mode(IODevice::ReadWrite);
|
||||||
set_error(0);
|
set_error(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
UdpSocket::UdpSocket(Object* parent)
|
UDPSocket::UDPSocket(Object* parent)
|
||||||
: Socket(Socket::Type::UDP, parent)
|
: Socket(Socket::Type::UDP, parent)
|
||||||
{
|
{
|
||||||
int fd = socket(AF_INET, SOCK_DGRAM | SOCK_NONBLOCK, 0);
|
int fd = socket(AF_INET, SOCK_DGRAM | SOCK_NONBLOCK, 0);
|
||||||
|
@ -53,7 +53,7 @@ UdpSocket::UdpSocket(Object* parent)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
UdpSocket::~UdpSocket()
|
UDPSocket::~UDPSocket()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,14 +30,14 @@
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
|
|
||||||
class UdpSocket final : public Socket {
|
class UDPSocket final : public Socket {
|
||||||
C_OBJECT(UdpSocket)
|
C_OBJECT(UDPSocket)
|
||||||
public:
|
public:
|
||||||
virtual ~UdpSocket() override;
|
virtual ~UDPSocket() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
UdpSocket(int fd, Object* parent = nullptr);
|
UDPSocket(int fd, Object* parent = nullptr);
|
||||||
explicit UdpSocket(Object* parent = nullptr);
|
explicit UDPSocket(Object* parent = nullptr);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
|
@ -35,7 +35,7 @@
|
||||||
#include <LibCore/File.h>
|
#include <LibCore/File.h>
|
||||||
#include <LibCore/LocalServer.h>
|
#include <LibCore/LocalServer.h>
|
||||||
#include <LibCore/LocalSocket.h>
|
#include <LibCore/LocalSocket.h>
|
||||||
#include <LibCore/UdpSocket.h>
|
#include <LibCore/UDPSocket.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
@ -176,7 +176,7 @@ Vector<String> LookupServer::lookup(const String& hostname, bool& did_timeout, u
|
||||||
|
|
||||||
auto buffer = request.to_byte_buffer();
|
auto buffer = request.to_byte_buffer();
|
||||||
|
|
||||||
auto udp_socket = Core::UdpSocket::construct();
|
auto udp_socket = Core::UDPSocket::construct();
|
||||||
udp_socket->set_blocking(true);
|
udp_socket->set_blocking(true);
|
||||||
|
|
||||||
struct timeval timeout {
|
struct timeval timeout {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue