1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 10:48:11 +00:00

LibCore: Add CSocket::bind() (virtual) and CSocket::listen().

These will be useful for implementing server sockets.
This commit is contained in:
Andreas Kling 2019-07-26 22:39:16 +02:00
parent 2f373a27a2
commit be2b585ca6
7 changed files with 42 additions and 4 deletions

View file

@ -2,14 +2,13 @@
#include <LibCore/CSocket.h>
#include <arpa/inet.h>
#include <errno.h>
#include <fcntl.h>
#include <netdb.h>
#include <netinet/in.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <unistd.h>
CSocket::CSocket(Type type, CObject* parent)
: CIODevice(parent)
@ -131,3 +130,10 @@ bool CSocket::send(const ByteBuffer& data)
ASSERT(nsent == data.size());
return true;
}
bool CSocket::listen()
{
int rc = ::listen(fd(), 5);
set_error(errno);
return rc == 0;
}