ladybird/Libraries/LibCore/CTCPSocket.cpp
Conrad Pankoff ed66f1d6d4 LibCore: Add CTCPServer
This is pretty much a find/replace copy of CLocalServer, and some
modifications to CTCPSocket and CSocketAddress to support it.
2019-08-05 12:53:07 +02:00

28 lines
581 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(fd);
} else {
set_fd(fd);
set_mode(CIODevice::ReadWrite);
set_error(0);
}
}
CTCPSocket::~CTCPSocket()
{
}