mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-03 15:16:14 +00:00
LibGUI: Add GTCPSocket and base class GSocket (inherits from GIODevice.)
And use these to do the line-by-line reading automagically instead of having that logic in IRCClient. This will definitely come in handy.
This commit is contained in:
19
LibGUI/GTCPSocket.cpp
Normal file
19
LibGUI/GTCPSocket.cpp
Normal file
@@ -0,0 +1,19 @@
|
||||
#include <LibGUI/GTCPSocket.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
GTCPSocket::GTCPSocket(GObject* parent)
|
||||
: GSocket(GSocket::Type::TCP, parent)
|
||||
{
|
||||
int fd = socket(AF_INET, SOCK_STREAM, 0);
|
||||
if (fd < 0) {
|
||||
set_error(fd);
|
||||
} else {
|
||||
set_fd(fd);
|
||||
set_mode(GIODevice::ReadWrite);
|
||||
set_error(0);
|
||||
}
|
||||
}
|
||||
|
||||
GTCPSocket::~GTCPSocket()
|
||||
{
|
||||
}
|
||||
Reference in New Issue
Block a user