mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-03 09:48:47 +00:00
The point of this function is to stash away the innermost error code so that we don't lose it by the time we get back to the client code.
28 lines
584 B
C++
28 lines
584 B
C++
#include <LibCore/CTCPSocket.h>
|
|
#include <sys/socket.h>
|
|
#include <errno.h>
|
|
|
|
CTCPSocket::CTCPSocket(Badge<CTCPServer>, int fd, CObject* parent)
|
|
: CSocket(CSocket::Type::TCP, parent)
|
|
{
|
|
set_fd(fd);
|
|
set_mode(CIODevice::ReadWrite);
|
|
set_error(0);
|
|
}
|
|
|
|
CTCPSocket::CTCPSocket(CObject* parent)
|
|
: CSocket(CSocket::Type::TCP, parent)
|
|
{
|
|
int fd = socket(AF_INET, SOCK_STREAM | SOCK_NONBLOCK, 0);
|
|
if (fd < 0) {
|
|
set_error(errno);
|
|
} else {
|
|
set_fd(fd);
|
|
set_mode(CIODevice::ReadWrite);
|
|
set_error(0);
|
|
}
|
|
}
|
|
|
|
CTCPSocket::~CTCPSocket()
|
|
{
|
|
}
|