LibCore: UDPServer::bind: Replace bind failure assert() with perror()

This commit is contained in:
Brendan Coles 2020-12-18 16:42:32 +00:00 committed by Andreas Kling
parent fe88f46bc9
commit 27a5c51f3f
Notes: sideshowbarker 2024-07-19 00:45:32 +09:00

View file

@ -62,12 +62,14 @@ bool UDPServer::bind(const IPv4Address& address, u16 port)
if (m_bound)
return false;
int rc;
auto saddr = SocketAddress(address, port);
auto in = saddr.to_sockaddr_in();
rc = ::bind(m_fd, (const sockaddr*)&in, sizeof(in));
ASSERT(rc == 0);
if (::bind(m_fd, (const sockaddr*)&in, sizeof(in)) != 0) {
perror("UDPServer::bind");
return false;
}
m_bound = true;
m_notifier = Notifier::construct(m_fd, Notifier::Event::Read, this);