2019-07-13 14:42:03 -03:00
|
|
|
#include <LibCore/CLocalSocket.h>
|
|
|
|
|
#include <sys/socket.h>
|
2019-07-26 17:39:16 -03:00
|
|
|
#include <errno.h>
|
2019-07-13 14:42:03 -03:00
|
|
|
|
2019-09-21 05:28:02 -03:00
|
|
|
CLocalSocket::CLocalSocket(int fd, CObject* parent)
|
2019-07-27 05:21:25 -03:00
|
|
|
: CSocket(CSocket::Type::Local, parent)
|
|
|
|
|
{
|
2019-09-22 16:46:46 -03:00
|
|
|
// NOTE: This constructor is used by CLocalServer::accept(), so the socket is already connected.
|
|
|
|
|
m_connected = true;
|
2019-07-27 05:21:25 -03:00
|
|
|
set_fd(fd);
|
|
|
|
|
set_mode(CIODevice::ReadWrite);
|
|
|
|
|
set_error(0);
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-13 14:42:03 -03:00
|
|
|
CLocalSocket::CLocalSocket(CObject* parent)
|
|
|
|
|
: CSocket(CSocket::Type::Local, parent)
|
|
|
|
|
{
|
2019-07-16 13:00:08 -03:00
|
|
|
int fd = socket(AF_LOCAL, SOCK_STREAM | SOCK_NONBLOCK | SOCK_CLOEXEC, 0);
|
2019-07-13 14:42:03 -03:00
|
|
|
if (fd < 0) {
|
2019-08-17 06:07:15 -03:00
|
|
|
set_error(errno);
|
2019-07-13 14:42:03 -03:00
|
|
|
} else {
|
|
|
|
|
set_fd(fd);
|
|
|
|
|
set_mode(CIODevice::ReadWrite);
|
|
|
|
|
set_error(0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CLocalSocket::~CLocalSocket()
|
|
|
|
|
{
|
|
|
|
|
}
|