mirror of
https://github.com/RGBCube/serenity
synced 2025-07-13 19:07:34 +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:
parent
d466f2634d
commit
8e3d0a23d5
12 changed files with 267 additions and 86 deletions
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()
|
||||
{
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue