2019-04-10 20:22:23 +02:00
|
|
|
#include <LibCore/CTCPSocket.h>
|
2019-03-18 14:09:58 +01:00
|
|
|
#include <sys/socket.h>
|
2019-08-05 20:47:30 +10:00
|
|
|
#include <errno.h>
|
|
|
|
|
2019-09-21 10:13:34 +02:00
|
|
|
CTCPSocket::CTCPSocket(int fd, CObject* parent)
|
2019-08-05 20:47:30 +10:00
|
|
|
: CSocket(CSocket::Type::TCP, parent)
|
|
|
|
{
|
|
|
|
set_fd(fd);
|
|
|
|
set_mode(CIODevice::ReadWrite);
|
|
|
|
set_error(0);
|
|
|
|
}
|
2019-03-18 14:09:58 +01:00
|
|
|
|
2019-04-10 20:22:23 +02:00
|
|
|
CTCPSocket::CTCPSocket(CObject* parent)
|
|
|
|
: CSocket(CSocket::Type::TCP, parent)
|
2019-03-18 14:09:58 +01:00
|
|
|
{
|
2019-04-08 04:53:45 +02:00
|
|
|
int fd = socket(AF_INET, SOCK_STREAM | SOCK_NONBLOCK, 0);
|
2019-03-18 14:09:58 +01:00
|
|
|
if (fd < 0) {
|
2019-08-17 11:07:15 +02:00
|
|
|
set_error(errno);
|
2019-03-18 14:09:58 +01:00
|
|
|
} else {
|
|
|
|
set_fd(fd);
|
2019-04-10 20:22:23 +02:00
|
|
|
set_mode(CIODevice::ReadWrite);
|
2019-03-18 14:09:58 +01:00
|
|
|
set_error(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-10 20:22:23 +02:00
|
|
|
CTCPSocket::~CTCPSocket()
|
2019-03-18 14:09:58 +01:00
|
|
|
{
|
|
|
|
}
|