mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 23:17:45 +00:00
LibCore: Allow TCPServer to be blocking
This commit is contained in:
parent
e1b0719435
commit
63b1296821
2 changed files with 12 additions and 0 deletions
|
@ -64,6 +64,17 @@ bool TCPServer::listen(const IPv4Address& address, u16 port)
|
|||
return true;
|
||||
}
|
||||
|
||||
void TCPServer::set_blocking(bool blocking)
|
||||
{
|
||||
int flags = fcntl(m_fd, F_GETFL, 0);
|
||||
VERIFY(flags >= 0);
|
||||
if (blocking)
|
||||
flags = fcntl(m_fd, F_SETFL, flags & ~O_NONBLOCK);
|
||||
else
|
||||
flags = fcntl(m_fd, F_SETFL, flags | O_NONBLOCK);
|
||||
VERIFY(flags == 0);
|
||||
}
|
||||
|
||||
RefPtr<TCPSocket> TCPServer::accept()
|
||||
{
|
||||
VERIFY(m_listening);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue