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:
parent
2f373a27a2
commit
be2b585ca6
7 changed files with 42 additions and 4 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue