mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 06:48:12 +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
|
@ -1,5 +1,6 @@
|
|||
#include <LibCore/CLocalSocket.h>
|
||||
#include <sys/socket.h>
|
||||
#include <errno.h>
|
||||
|
||||
CLocalSocket::CLocalSocket(CObject* parent)
|
||||
: CSocket(CSocket::Type::Local, parent)
|
||||
|
@ -17,3 +18,11 @@ CLocalSocket::CLocalSocket(CObject* parent)
|
|||
CLocalSocket::~CLocalSocket()
|
||||
{
|
||||
}
|
||||
|
||||
bool CLocalSocket::bind(const CSocketAddress& address)
|
||||
{
|
||||
auto un = address.to_sockaddr_un();
|
||||
int rc = ::bind(fd(), (const sockaddr*)&un, sizeof(un));
|
||||
set_error(errno);
|
||||
return rc == 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue