Skip to content

Commit

Permalink
LibCore: UDPServer::bind: Replace bind failure assert() with perror()
Browse files Browse the repository at this point in the history
  • Loading branch information
bcoles authored and awesomekling committed Dec 18, 2020
1 parent fe88f46 commit 27a5c51
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions Libraries/LibCore/UDPServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 27a5c51

Please sign in to comment.