Skip to content

Commit

Permalink
Improved logging/debugging.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Oct 27, 2023
1 parent 204482a commit 7aeb3dd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
10 changes: 9 additions & 1 deletion source/Protocol/QUIC/Address.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,17 @@ namespace Protocol
this->length = length;
}

static const char * family_name(int family) {
switch (family) {
case AF_INET: return "AF_INET";
case AF_INET6: return "AF_INET6";
default: return "AF_UNKNOWN";
}
}

std::ostream & operator<<(std::ostream & output, const Address & address)
{
output << "<Address family=" << address.data.sa.sa_family << " address=" << address.to_string() << ">";
output << "<Address family=" << family_name(address.data.sa.sa_family) << " address=" << address.to_string() << ">";

return output;
}
Expand Down
6 changes: 5 additions & 1 deletion source/Protocol/QUIC/Socket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,11 @@ namespace Protocol

void Socket::close() {
if (_descriptor >= 0) {
::close(_descriptor);
auto result = ::close(_descriptor);

if (result == -1) {
throw std::system_error(errno, std::generic_category(), "close");
}

_descriptor = -1;
}
Expand Down

0 comments on commit 7aeb3dd

Please sign in to comment.