mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-08 12:19:37 +03:00
1222b94ab8
Compiling LibCore on macOS is needed if one wants to compile host tools (like IPCCompiler) on a non Linux host. These changes could be possibly reverted once "event loop" functionality and "base library" (Vector, String etc.) will be split in two separate libraries, updating all relevant projects.
44 lines
953 B
C++
44 lines
953 B
C++
#include <LibCore/CLocalSocket.h>
|
|
#include <sys/socket.h>
|
|
#include <errno.h>
|
|
|
|
#ifndef SOCK_NONBLOCK
|
|
#include <sys/ioctl.h>
|
|
#endif
|
|
|
|
CLocalSocket::CLocalSocket(int fd, CObject* parent)
|
|
: CSocket(CSocket::Type::Local, parent)
|
|
{
|
|
// NOTE: This constructor is used by CLocalServer::accept(), so the socket is already connected.
|
|
m_connected = true;
|
|
set_fd(fd);
|
|
set_mode(CIODevice::ReadWrite);
|
|
set_error(0);
|
|
}
|
|
|
|
CLocalSocket::CLocalSocket(CObject* parent)
|
|
: CSocket(CSocket::Type::Local, parent)
|
|
{
|
|
|
|
#ifdef SOCK_NONBLOCK
|
|
int fd = socket(AF_LOCAL, SOCK_STREAM | SOCK_NONBLOCK | SOCK_CLOEXEC, 0);
|
|
#else
|
|
int fd = socket(AF_LOCAL, SOCK_STREAM, 0);
|
|
int option = 1;
|
|
ioctl(fd, FIONBIO, &option);
|
|
fcntl(fd, F_SETFD, FD_CLOEXEC);
|
|
#endif
|
|
|
|
if (fd < 0) {
|
|
set_error(errno);
|
|
} else {
|
|
set_fd(fd);
|
|
set_mode(CIODevice::ReadWrite);
|
|
set_error(0);
|
|
}
|
|
}
|
|
|
|
CLocalSocket::~CLocalSocket()
|
|
{
|
|
}
|