Commit 1f3ce380 authored by Max Kellermann's avatar Max Kellermann

net/SocketAddress: reimplement GetPort() using IPv4Address::GetPort()

parent dfc1f634
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include "config.h" #include "config.h"
#include "SocketAddress.hxx" #include "SocketAddress.hxx"
#include "IPv4Address.hxx"
#include "IPv6Address.hxx" #include "IPv6Address.hxx"
#include "util/StringView.hxx" #include "util/StringView.hxx"
...@@ -96,7 +97,7 @@ SocketAddress::GetPort() const noexcept ...@@ -96,7 +97,7 @@ SocketAddress::GetPort() const noexcept
switch (GetFamily()) { switch (GetFamily()) {
case AF_INET: case AF_INET:
return ntohs(((const struct sockaddr_in *)(const void *)address)->sin_port); return IPv4Address(*this).GetPort();
case AF_INET6: case AF_INET6:
return IPv6Address(*this).GetPort(); return IPv6Address(*this).GetPort();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment