mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-10 13:00:29 +03:00
LibCore: Allow TCPServer to be blocking
This commit is contained in:
parent
e1b0719435
commit
63b1296821
Notes:
sideshowbarker
2024-07-18 12:12:35 +09:00
Author: https://github.com/stelar7 Commit: https://github.com/SerenityOS/serenity/commit/63b1296821f Pull-request: https://github.com/SerenityOS/serenity/pull/7467 Reviewed-by: https://github.com/awesomekling
@ -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);
|
||||
|
@ -19,6 +19,7 @@ public:
|
||||
|
||||
bool is_listening() const { return m_listening; }
|
||||
bool listen(const IPv4Address& address, u16 port);
|
||||
void set_blocking(bool blocking);
|
||||
|
||||
RefPtr<TCPSocket> accept();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user